0
Good morning! I am going through more moments and I would like your help with this problem!
Come on, I’m doing a select in MYSQL where several tables are selected, in opencart to generate an XML for facebook ads.
My XML code looks like this
SELECT DISTINCT t1.product_id as product_idT1, t1.manufacturer_id as manufaturer, t1.price as price, t1.date_added as dataAdd, t1.quantity as quantity, t2.name as nameT2, t2.description as descriptionT2, t3.name as nameT3, t4.name as nameT4, t5.image, t6.name as nameT6, t7.query as urlT7, t7.keyword as keyword
FROM oc_product t1
INNER JOIN oc_product_description t2 ON (t1.product_id = t2.product_id)
INNER JOIN oc_manufacturer t3 ON (t1.manufacturer_id = t3.manufacturer_id)
INNER JOIN oc_option_value_description t4
INNER JOIN oc_product_image t5 ON (t1.product_id = t5.product_id)
INNER JOIN oc_stock_status t6 ON (t1.stock_status_id = t6.stock_status_id)
INNER JOIN oc_url_alias t7
WHERE t7.query like CONCAT('%', t1.product_id , '%')
GROUP BY product_idT1 ASC
Only in this case, the picture table oc_product_image needs to be in DECREASING order because I want the last image.
I am using PHP.
Thank you!
ORDER BY T5.image DESC, t1.product_id
– Caique Romero
Show... thank you so much! But still not what I need =/
– Cristiano Facirolli
Explain better your need, if the solution is not a simple
order by
, what is your difficulty?– Andrey
I need it to return in descending order Ex: Product 1(oc_product) - Photo 1 (oc_product_image) Product 2(oc_product) - Photo 2 (oc_product_image) But I don’t know why my first photo in the register, it’s getting like the last one! Gave to understand ^^
– Cristiano Facirolli
It’s a little confusing yet, but from what I understand it would be simple:
ORDER BY t5.product_id DESC
. But in your last comment, I honestly had the impression that you were wanting Ascendant order and not Descendant... but see if the solution I posted meets your need.– Andrey
Thank you, that’s right! Thank you very much
– Cristiano Facirolli
Reactivating the question again, this query would be to list all products but not this listing, it is hiding about 90 results, could tell me where I am missing?
– Cristiano Facirolli