I have an sql query:
DELETE **x**
FROM $table **x**
JOIN
( SELECT vendors
, email
, MIN(lead_id) **min_lead_id**
FROM $table
WHERE vendors = $vendor
GROUP BY vendors
, email
) y
ON **y**.vendors = **x**.vendors
AND **y**.email = **x**.email
AND **y**.**min_lead_id** <> **x**.lead_id
I’m trying to understand it. I learned all the basics of sql. However the bolded variables(?)(x, y, min_lead_id) in the code sample boggles me. I have never encountered those and I dont know what google keywords I need to search for to get information. They dont show up in any of the sql documentation I have access to.
Can someone please point me in the right direction?
They are
aliasesfor the tables and subqueries in your query.It is optional to put an
ASbetween the item and its alias to make this definition clearer