• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

list of non categories

Guest
Aug 07, 2007 Aug 07, 2007

Copy link to clipboard

Copied

Hi i have 2 tables, ProductsTable PT and CatToProducts CTP

i want a list productID from the ProductsTable that do not have a entry in the CatToProducts table

i have tried

WHERE PT.Products_ID <> CTP.ProductID99

but that gives me wrong results?
TOPICS
Advanced techniques

Views

411

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Aug 07, 2007 Aug 07, 2007

Copy link to clipboard

Copied

Of course, syntax is database-dependent, but something like this should work

select PT.productID
from ProductsTable PT left outer join CatToProducts CTP on CTP.ProductID99 = PT.Products_ID
where CTP.ProductID99 is null

The outer join causes the linked table to have null values in all fields for rows which do not match the driving table.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
Aug 08, 2007 Aug 08, 2007

Copy link to clipboard

Copied

LATEST
Try something like:

SELECT PT.Products_ID FROM ProductsTable PT WHERE PT.Products_ID not in (SELECT CTP.ProductID99 FROM CatToProducts CTP)

Thanks

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources
Documentation