Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Rhinorhino on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

MySQL Driving me nuts!!!

Status
Not open for further replies.

ExpertTEK

IS-IT--Management
Joined
Apr 14, 2004
Messages
2
Location
US
I have this two tables...

subcategoria
=======================
cod_subcat, cod_cat, subcat
1, 2, União
2, 2,Pérola
3, 3, Pilão
4, 3, Capital
5, 3, Canaan
6, 1, Votorantim
12, 1, Irajázinho
11, 3, Fazenda

fornecedor_subcategoria (cod_dubcat = Primary Key)
=======================
cod_forn, cod_subcat
1, 1
1, 2
1, 3
1, 4
3, 6
3, 12
1, 5
1, 11
1, 12

There are 8 categories. I need to SELECT the 'subcat' from table 'subcategoria' WHERE 'cod_subcat' NOT IN (NOT EXIST) 'cod_forn'

How can I make this MySQL statement?

Thank you.
 
How about something like:
[tt]
SELECT s.subcat
FROM
subcategoria s
LEFT JOIN fornecedor_subcategoria f
ON s.cod_subcat=f.cod_forn
WHERE f.cod_forn IS NULL
[/tt]


-----
ALTER world DROP injustice, ADD peace;
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top