Sounds like you want to do: Select store_name, t1mgr.manager_name as 'type_1_manager', t2mgr.manager_name as 'type_2_manager' >From (keystone_stores ks left join managers t1mgr on ks.id = t1mgr.store_id and t1mgr.manager_type = 1) Left join managers t2mgr on ks.id = t2mgr.store_id and t2mgr.manager_type = 2
Does that fit the bill? Ted Gifford -----Original Message----- From: Gregory A. Swarthout [mailto:[EMAIL PROTECTED] Sent: Tuesday, February 24, 2004 9:09 AM To: [EMAIL PROTECTED] Subject: Help with a query Suppose I have two tables like this: keystone_stores managers ======================== ================================================= id | store_name id | manager_name | manager_type | store_id ----+------------------- ----+-------------------+--------------+--------- AA | Wilshire's Oakland 1 | Fred Williams | 1 | AA FR | Wilshire's Redmond 2 | Janice Plain | 2 | AA LI | Dan's Food & Drug 3 | Janet Gilmore | 1 | FR 4 | Nick Woolstune | 2 | FR 5 | Ken Jennings | 1 | LI 6 | Fred Muelmann | 2 | LI Given that there will be exactly one of each of the two types of managers per store, is there a way to write a query that will generate the following result set? store_name | type_1_manager | type_2_manager -------------------+----------------+--------------- Wilshire's Oakland | Fred Williams | Janice Plain Wilshire's Redmond | Janet Gilmore | Nick Woolstune Dan's Food & Drug | Ken Jennings | Fred Muelmann Can this be done in a single query? Greg -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe: http://lists.mysql.com/[EMAIL PROTECTED] -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe: http://lists.mysql.com/[EMAIL PROTECTED]