sql - Selecting all rows whos foreign key points to a specific primary key? -


I have two tables with an 'User' table, in the table, each row (user) has a unique ID (primary key).

The second table is a 'Tasks' table that contains a foreign key in each row in the work table that indicates the user (in the user table) who owns that task.

Using SQL Express 2008, what query should I use to get a list of all tasks assigned to a user? For example, if I have a primary key of 0 in the user's table and 10 rows in the work table, it means that this user has 10 functions assigned. I need to create a query that gives me 10 rows from the work table.

If you have a user select pk

  tasks. * Select from tasks where taskss.UserId = 0  

if you have a user name

  functions. * User.USIR = function on user From users who are working on the user User name. Username = 'Bob'  

Comments