hi
how to have multiple select in one query
for ex :
'SELECT * FROM item ORDER BY sale_count DESC LIMIT 3; SELECT * FROM item ORDER BY view_count LIMIT 3'
i dont want to make multiple query separately, coz i think it increase the overhead
You need to use JOIN clause.
-
INNER JOIN: Returns all rows when there is at least one match in BOTH tables
-
LEFT JOIN: Return all rows from the left table, and the matched rows from the right table
-
RIGHT JOIN: Return all rows from the right table, and the matched rows from the left table
-
FULL JOIN: Return all rows when there is a match in ONE of the tables
robsch
(Robert Schneider)
3
How would you use joins with this? I would rather use a union (Doc for union).
I don’t know the circumstances but I think two queries would be also okay.