![]() |
| |||||||
![]() |
| | LinkBack | Thread Tools | Search this Thread | Display Modes |
| |||
| <ukr_bend@yahoo.com> wrote in message news:1143157218.419817.99930@e56g2000cwe.googlegro ups.com... > Hi > > I have two select statements that work correctly. They are as > follows: > > SELECT DISTINCT user.* FROM user_tab AS user INNER JOIN user_pref_tab > AS pref ON user.id=pref.userid and pref.questionid = '20' > > SELECT DISTINCT user.* FROM user_tab AS user LEFT JOIN user_pref_tab > AS pref ON user.id=pref.userid WHERE pref.userid IS NULL > > The first simply returns all rows that have the same userid in the > user and preferences table that also have the column "questionid" as a > value of 20. > > The second just returns every row that doesn't have a matching userid > in both tables. > > The problem is I desperately need to combine these two statements in > to ONE. It seems like it should be possible but I have tried about a > 100 different combination of joins and nested selects and can't get the > result I want. And what result would that be? -- Martijn Tonies Database Workbench - development tool for MySQL, and more! Upscene Productions http://www.upscene.com My thoughts: http://blog.upscene.com/martijn/ Database development questions? Check the forum! http://www.databasedevelopmentforum.com |
![]() |
| Thread Tools | Search this Thread |
| Display Modes | |
| |