views:

47

answers:

2

Hello. I have two tables in my database, and I would like to retreive information from both of them without having to do two queries. Basically, the user_ID(s) retreived from the tasks table needs to be used to get those respective user(s) names from the users table. This is what I have so far, but the query is returning false:

SELECT t.user_id, t.nursery_ss, t.nursery_ws, t.greeter, t.date
   u.user_first_name, u.user_last_name
   FROM tasks_tbl AS t
   INNER JOIN users_tbl AS u ON t.user_id = u.user_id
   WHERE t.date = '2009-11-29'

Any suggestions would be appreciated. Thanks.

A: 

Actually, your query looks good; you might try checking to see if other aspects of the query are faulty. For example, try just a SELECT * from your join as specified. Or try omitting your WHERE clause; you'll get more data than you want, but it may help you debug your query.

McWafflestix
+3  A: 

You forgot a comma after t.date in your select-list:

SELECT t.user_id, t.nursery_ss, t.nursery_ws, t.greeter, t.date -- comma needed here
   u.user_first_name, u.user_last_name
FROM tasks_tbl AS t
INNER JOIN users_tbl AS u ON t.user_id = u.user_id
WHERE t.date = '2009-11-29'
Bill Karwin