Garayed.com  

Go Back   Garayed.com > mySQL
FAQ Members List Calendar Search Today's Posts Mark Forums Read


Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 03-24-2006, 03:54 PM
Martijn Tonies
 
Posts: n/a
Default Re: Combing two simple select statements. There must be a way?


<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


Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT. The time now is 11:52 AM.




LinkBacks Enabled by vBSEO 3.0.0 © 2007, Crawlability, Inc.