Excluding

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hello,

I've got a table containing suppliers (two fields: supplier_code and
supplier_name) and another one containing suppliers' codes to exclude from
showing up. Since I've got more than 45 suppliers to exclude, I've given up
with the idea of putting everything in the criteria with the "not like"
expression.

Is someone know how to perform this condition in my query? If yes, any
suggestions?

Thanks,
gmore
 
/* Powered by General SQL Parser (www.sqlparser.com) */

SELECT S.supplier_code,
S.supplier_name
FROM tbl_suppliers AS S
LEFT JOIN tbl_exclude AS E
ON S.supplier_code = E.supplier_code
WHERE E.supplier_code IS NULL

tbl_suppliers - the table that you want to select the data from
tbl_exclude - the table with the supplied codes you want to exclude

This will select all records from tbl_suppliers where there is no
match in tbl_exclude.

Cheers,
Jason Lepack
 
Thanks

Jason Lepack said:
/* Powered by General SQL Parser (www.sqlparser.com) */

SELECT S.supplier_code,
S.supplier_name
FROM tbl_suppliers AS S
LEFT JOIN tbl_exclude AS E
ON S.supplier_code = E.supplier_code
WHERE E.supplier_code IS NULL

tbl_suppliers - the table that you want to select the data from
tbl_exclude - the table with the supplied codes you want to exclude

This will select all records from tbl_suppliers where there is no
match in tbl_exclude.

Cheers,
Jason Lepack
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top