Currently, I have encountered A problem about the sorting of query results in php. first, table A queries the detailed results of A batch of products, but you need to sort these results again, the sorting is based on the condition in Table B that if the product ID in table A exists in the field in Table B (the field format is the set of product IDs in Table A: 355,223,367) for example, php query sorting
Currently, I have encountered a problem about sorting query results.
First, A batch of product details are displayed in Table.
However, this batch of results needs to be sorted again, and the sorting is based on Table B.
The condition is that if the product ID in table A exists in the field in Table B (the field format is the set of product IDs in Table A: 355,223,367)
If the product with the ID of 355,223,367 exists in the field of Table B, the three products are listed at the top of the list.
Is there any way to achieve this effect? Or you can sort the queried array.
------ Solution --------------------
Use left join order by the ID of product A in product B
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.
A Free Trial That Lets You Build Big!
Start building with 50+ products and up to 12 months usage for Elastic Compute Service