Explain a SELECT statement for MySQL
someone can explain me what this query does?
$sql=mysql_query("SELECT b.id, b.data FROM data_parent a, data b WHERE b.id=a.did and parent='$id'");
it works but honestly i didn't unde开发者_运维百科rstand.
Thanks
- Take the table
data_parent
and alias it asa
. - Take the table
data
and alias it asb
. - Match values in
a
with those inb
on theid
column inb
and thedid
column ina
. - Filter for rows in [some table since it isn't specified] such that the column
parent
is equal to some passed in value. - From those results, display the
id
anddata
columns fromb
The query grabs the COlumns ID & Data from the Data table where the data_parentID is the same as the data table id. And it is based on for 1 parent ID
精彩评论