Sunday, September 26, 2010

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

Programmer Question

I have two tables. One is a 'Users' table. Each row (user) in the table has a unique id (primary key).



The second table is a 'Tasks' table. Each row in the Tasks table has a foreign key which points to the user (in the Users table) that owns that task.



Using SQL Express 2008, what query must I use to obtain a list of all tasks assigned to a user? For example, if I have a user in the Users table with a primary key of 0 and there are 10 rows in the Tasks table with a foreign key value of 0, that means that this user has 10 tasks assigned to him. I need to build a query that gives me these 10 rows from the Tasks table.



Find the answer here

No comments:

Post a Comment

LinkWithin

Related Posts with Thumbnails