I've got the following SQL query:
What I'm trying to do is retrieve a single row for each attribute that contains the information from both the products_attributes and products_attributes_download tables (in addition to a couple of "defining" fields).Code:SELECT pa.*, pad.*, p.products_model, po.products_options_name, pov.products_options_values_name FROM products AS p, products_options AS po, products_options_values AS pov, products_attributes AS pa LEFT JOIN products_attributes_download AS pad ON (pa.products_attributes_id = pad.products_attributes_id) WHERE pa.products_id = p.products_id AND pa.options_id = po.products_options_id AND po.language_id = 1 AND pa.options_values_id = pov.products_options_values_id AND pov.language_id = 1 ORDER BY pa.products_id ASC, pa.options_id ASC, pa.options_values_id ASC
The query is working except that the products_attributes_id value is coming back as "NULL" unless there's a companion record in the products_attributes_download table, in which case it's properly returning the numerical attributes_id. Is there some MySQL "magic" that will cause the result to be returned with those index values, i.e. so the query works the same as when it's run via phpMyAdmin?


Reply With Quote

