dbTalk Databases Forums  

SQL Problem

comp.databases.mysql comp.databases.mysql


Discuss SQL Problem in the comp.databases.mysql forum.



Reply
 
Thread Tools Display Modes
  #11  
Old   
Doug Miller
 
Posts: n/a

Default Re: SQL Problem - 05-05-2011 , 09:12 PM






In article <1d584d94-8944-437d-b6f0-6bfd4e2407f6 (AT) r20g2000yqd (DOT) googlegroups.com>, bruce <bruceaj (AT) bellsouth (DOT) net> wrote:
Quote:
I guess it's my inexperience but I cannot figure out how to write SQL
for the following case:

I have two tables. Table1 has the numbers 1 through 100 (no
duplicates). The Table2 has "Some" of the numbers 1 through 100 and
there may be duplicates in Table2. I would like to SELECT a list of
the numbers missing from Table2.

And to carry it one step further. I want to use the numbers missing
from Table2 to SELECT the rows from TABLE 1 with these numbers. This
is the final result.
SELECT Table1.Number, Table1.OtherColumns
FROM Table1 LEFT JOIN Table2 ON (Table1.Number = Table2.Number)
WHERE Table2.Number IS NULL
;

Reply With Quote
  #12  
Old   
Lennart Jonsson
 
Posts: n/a

Default Re: SQL Problem - 05-06-2011 , 12:58 AM






On 2011-05-06 01:02, Geoff Muldoon wrote:
[...]
Quote:
RTFM on the use of the MINUS function
AFAIK mysql does not implement minus (which is a set operation in other
dbms, not a function). Can you be more specific on where to read up on this?

/Lennart

Reply With Quote
  #13  
Old   
Geoff Muldoon
 
Posts: n/a

Default Re: SQL Problem - 05-08-2011 , 06:28 PM



erik.lennart.jonsson (AT) gmail (DOT) com says...

Quote:
AFAIK mysql does not implement minus (which is a set operation in
other
dbms, not a function). Can you be more specific on where to read up on this?
Ah yes, my bad.

Forgot that MySQL doesn't implement the ANSI standard (actually in the
ANSI standard it is called EXCEPT instead of MINUS, which is and Oracle-
specific ontology) in this area.

GM

Reply With Quote
Reply




Thread Tools
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



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.