List:General Discussion« Previous MessageNext Message »
From:Geoffrey Sneddon Date:June 7 2006 4:25pm
Subject:Joins - Multiple rows from a single table
View as plain text  
I've got the following query:

SELECT `bugs`.`id`, `bugs`.`assignee`, `users`.`username`,  
`bugs`.`submitter` FROM `fb_bugs` AS `bugs`, `fb_users` AS `users`  
WHERE `users`.`id` = `bugs`.`assignee`

My problem is that I also want the `users`.`username` for  
`bugs`.`submitter`. How can I do that?

Also, anyway to make the entire query better (the above is just the  
relevant part):

SELECT `bugs`.`id`, `bugs`.`title`, UNIX_TIMESTAMP 
(`bugs`.`submitted`), `bugs`.`fix`, `bugs`.`assignee`,  
`users`.`username`, `bugs`.`category`, `category`.`name`,  
`bugs`.`version`, `version`.`name`, `bugs`.`priority`,  
`bugs`.`haspatch`FROM `fb_bugs` AS `bugs`, `fb_users` AS `users`,  
`fb_category` AS `category`, `fb_versions` AS `version` WHERE  
`users`.`id` = `bugs`.`assignee` AND `category`.`id` =  
`bugs`.`category` AND `version`.`id` = `bugs`.`version`

Help will very much be appreciated, as SQL like this really isn't  
what I'm good at :)

- Geoffrey Sneddon



Thread
Joins - Multiple rows from a single tableGeoffrey Sneddon7 Jun
  • Re: Joins - Multiple rows from a single tablePeter Brawley7 Jun
    • Re: Joins - Multiple rows from a single tableGeoffrey Sneddon7 Jun
    • Re: Joins - Multiple rows from a single tableGeoffrey Sneddon7 Jun