I have the following MYSQL select statement in a php file that was provided me by a programmer sometime ago.
I’m trying to make some edits to the file (I know enough PHP to “get myself into trouble”).
Unfortunately, I don’t understand this statement and what it means. I’ve never seen a select statement with “DOTS” in it (ie. a.weight or b.oil_type_id)
I don’t understand howto read it. Here’s the statement. Anyone know what this is supposed to mean?
$query11 = "SELECT avg(a.weight) as weight_avg
from oil_type a, oil_data b
where b.oil_type_id = a.oiltype_id
and b.viscosity_id = ". $viscosity_id_this;
You are qualifying the columns with their table names (or rather, their aliases):
This is necessary to remove ambiguity (ie: when a column with the same name exists in both tables). If the column names are not the same, you could use this for clarity.
The whole query could be rewritten as:
Which might be more clear (or not).