For Programmers: Free Programming Magazines  


Home > Archive > PHP SQL > August 2004 > newbie: select









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author newbie: select
xEM

2004-08-29, 8:56 am

I want to list rows from TABLE_A that have not equivalent value of column
ID in TABLE_B. How do that?

Example:

TABLE_A
ID
1
2
3
4
5
6

TABLE_B
ID
1
3
4

I want to get TABLE_RESULT that have:
TABLE_RESULT
ID
2
5
6

Thanks.


--
pozdr.;)
~xEM
Floortje

2004-08-29, 8:56 am

> I want to list rows from TABLE_A that have not equivalent value of column
> ID in TABLE_B. How do that?
>



SELECT * FROM blaat WHERE tablea <> tableb
or
SELECT * FROM blaat WHERE tablea NOT tableb

etc


J.O. Aho

2004-08-29, 8:56 am

xEM wrote:
> I want to list rows from TABLE_A that have not equivalent value of column
> ID in TABLE_B. How do that?


Depending on your SQL server, you can do multiple SELECTs (result from the
SELECTs of ID in TABLE_B is matched against ID in TABLE_A), other way to do
this is to JOIN the tables and select those rows where TABLE_B.ID = NULL
(TABLE_B.ID IS NULL).

For more info about join, you can take a look at the MySQL online
documentation with user comments:

http://dev.mysql.com/doc/mysql/en/JOIN.html
http://dev.mysql.com/doc/mysql/en/L...timization.html


Have fun...


//Aho
Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com