I have this main query here:
SELECT tbl_vehicles.id, tbl_vehicles.Model, tbl_vehicles.Brand, tbl_vehicles.isAutoTrans, tbl_vehicles.Seats, tbl_vehicles.Price, tbl_brands.BrandName
FROM tbl_vehicles
INNER JOIN tbl_brands
ON tbl_vehicles.Brand=tbl_brands.id
ORDER BY id
and i need to get 9 random results of the above query. I found this answer here which is exactly what I need.
SELECT * FROM tbl_vehicles AS r1 JOIN (SELECT CEIL(RAND() * (SELECT MAX(id) FROM tbl_users)) AS id) AS r2 WHERE r1.id >= r2.id ORDER BY r1.id ASC LIMIT 9
How can I put them together and keep my inner join?
Obviously my structure is wrong but why?
SELECT * FROM tbl_vehicles INNER JOIN tbl_brands ON tbl_vehicles.Brand=tbl_brands.id ORDER BY id AS r1 JOIN (SELECT CEIL(RAND() * (SELECT MAX(id) FROM tbl_users)) AS id) AS r2 WHERE r1.id >= r2.id ORDER BY r1.id ASC LIMIT 9