Select Rows Where Value from One Column Matches Other Column

Posted by in Software, Tutorial

TL;DR: Use a JOIN.

I’ve got a table representing a tree, using two columns:

and I want to select all children for parents whose CLASS_ID have a certain value (e.g. abcd).

The way I could do it was via a JOIN statement:

This will:

  • Perform a join where child.parent_prop_id = parent.prop_id
  • Filter only parent.class_id = 'abcd'



This will work with other databases as well :)


A little experiment: If you find this post and ad below useful, please check the ad out :-)