I want to fetch data from three tables that are Products, Attributes and features
One product may have multiple features and attributes
I am using query
select *
from products p, features f, attributes a
where p.id =1 and p.id = f.id and p.id = a.id
I want to know if the query is ok ???
You are using
ANSI SQL-89syntax. But I’ll recommend to useANSI SQL-92syntax. Example of that is below:in that way you have to explicitly define their relationship (the
ONclause) in order to avoid syntax error. TheANSI SQL-89syntax is prone to error and you might not notice it because it will not produce an error. ExampleWithout defining the relationship field, it will still execute but gives you invalid result. From
INNER JOIN, it is nowCROSS JOINAdditional Information
Read something here
MySQL JOIN Tutorials