TFW you send 60 minutes wrestling with a SQL query and you're still not even sure why it works now (geek overload)
Posted by
oblique (aka kkuphal)
Nov 5 '21, 07:46
|
Trying to filter out Tickets that have a parent (IE: subtasks). Because of how the system I'm working with works, I have to select from TABLE but The "Parent ID" is in another table so do a quick:
SELECT * FROM TABLE WHERE ID NOT IN (SELECT PARENT_ID FROM OTHERTABLE)
This should give me IDs which are NOT set as Parent_IDs, right?
Doesn't work.
SELECT * FROM TABLE WHERE ID NOT IN (SELECT ID FROM OTHERTABLE WHERE PARENT_ID IS NOT NULL)
This does.
|
Responses:
|