Question : Display all rows except rows that are related to another within the same table (PARENT/CHILD)

We have an inventory table where within the table, there are items knowned as CHILDS that related to items within the same table that are PARENTS (see attachment)

We're working on a report with help with EE qhere we're trying to list all records from an inventory table, except those that are PARENTS (these are Items that has other Items pointing to them).

Answer : Display all rows except rows that are related to another within the same table (PARENT/CHILD)

Use EXISTS. will perform faster than "not in".

1:
2:
select * from yourtable a
where not exists(select 1 from yourtable where a.id = childparentrelate)
Random Solutions  
 
programming4us programming4us