SELECT eshop_dalsi_obrazky.*, eshop_zbozi.*
from eshop_zbozi
left join eshop_dalsi_obrazky
on (eshop_zbozi.idZbozi=eshop_dalsi_obrazky.eshop_zbozi_idZbozi)
where idObrazky is not null
LIMIT 12 order by rand();
答案 0 :(得分:0)
我认为您失败的原因是您limit
之前有order by
。请改变它:
SELECT eshop_dalsi_obrazky.*, eshop_zbozi.*
from eshop_zbozi left join eshop_dalsi_obrazky on (eshop_zbozi.idZbozi=eshop_dalsi_obrazky.eshop_zbozi_idZbozi)
where idObrazky is not null order by rand() LIMIT 12
答案 1 :(得分:0)
请更改限制地点
SELECT eshop_dalsi_obrazky.*, eshop_zbozi.* from eshop_zbozi left join
eshop_dalsi_obrazky on (eshop_zbozi.idZbozi=eshop_dalsi_obrazky.eshop_zbozi_idZbozi)
where idObrazky is not null LIMIT 12;
OR 你可以尝试这也可以帮助你
SELECT * FROM (SELECT eshop_dalsi_obrazky.*, eshop_zbozi.* from eshop_zbozi left join
eshop_dalsi_obrazky on (eshop_zbozi.idZbozi=eshop_dalsi_obrazky.eshop_zbozi_idZbozi)
where idObrazky is not null LIMIT 12) as tmpTbl order by rand();
答案 2 :(得分:0)
ORDER
出现在LIMIT
之前。它应该是:
SELECT
eshop_dalsi_obrazky . *, eshop_zbozi . *
from
eshop_zbozi
left join
eshop_dalsi_obrazky ON (eshop_zbozi.idZbozi = eshop_dalsi_obrazky.eshop_zbozi_idZbozi)
where
idObrazky is not null
order by rand()
LIMIT 12;