Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Searching for a precise term for a SQL phrase

Tags:

sql

I'm trying to document some SQL and wanted to get the right terminology. If you write SQL like so;

select child.ID, parent.ID
from hierarchy child 
inner join hierarchy parent 
on child.parentId = parent.ID

Then you have one actual table ('hierarchy') which you are giving two names ('parent' and 'child') My question is about how you refer to the logical entity of a table with a name.

What would you write in the blank here for the name?

"This query uses one table (hierarchy) but two _ (child and parent)"

[edit] left a previous draft in the question. now corrected.

like image 366
Steve Cooper Avatar asked Dec 17 '22 21:12

Steve Cooper


1 Answers

I believe this is called a SELF JOIN. A and B (or "child" and "parent", I think you have a typo in your question) are called ALIASes or TABLE ALIASes.

like image 79
Larry Lustig Avatar answered Dec 28 '22 06:12

Larry Lustig