Easy SQL post-need help!

  • I have a simple SQL table.  The data looks like this:

    products_ID----category----product_local

    1----CORE----0

    2----BASE----0

    3----BRANCH----1

    4----LEAF----3

    I need to create a SQL statement that produces all category items where that ROW's products_ID is not found in ANY product_local in the table.  So in the table above only the category BASE and LEAF would be printed because their products_ID are not found in any product_local in the table.

    TIA as I am completely stuck!

  • I had to read your description a few times before understanding it.   I get it now.  Here's what you need:

    select *

    from table

    where products_ID not in (select product_local from table);

    you would substitute your actual table name.

    this statement uses what is called a subquery (highly useful)

    this will work, there is a way to make the subquery more exact but I didn't want to add complexity.

    Mike

Viewing 2 posts - 1 through 1 (of 1 total)

You must be logged in to reply to this topic. Login to reply