SELECT e.ent_seq,
GROUP_CONCAT(DISTINCT kei.keb SEPARATOR'; ')AS kebs,
GROUP_CONCAT(DISTINCT rei.reb SEPARATOR '; ') AS rebs,
GROUP_CONCAT(DISTINCT sei.mean SEPARATOR '; ') AS means,
FROM entry e
LEFT JOIN k_ele kei ON e.entry = kei.entry
LEFT JOIN r_ele rei ON e.entry = rei.entry
LEFT JOIN sense se ON e.entry = se.entry
LEFT JOIN s_gloss_eng sei ON se.SID = sei.SID
WHERE mn_null = 1
GROUP BY e.entry
如何随机选择e.entry? e.entry是一个int。
答案 0 :(得分:1)
SELECT e.ent_seq,
GROUP_CONCAT(DISTINCT kei.keb SEPARATOR'; ')AS kebs,
GROUP_CONCAT(DISTINCT rei.reb SEPARATOR '; ') AS rebs,
GROUP_CONCAT(DISTINCT sei.mean SEPARATOR '; ') AS means
FROM entry e
LEFT JOIN k_ele kei ON e.entry = kei.entry
LEFT JOIN r_ele rei ON e.entry = rei.entry
LEFT JOIN sense se ON e.entry = se.entry
LEFT JOIN s_gloss_eng sei ON se.SID = sei.SID
WHERE e.ent_seq IN (SELECT jt5.jlpt5_seq FROM jlptn5 jt5
WHERE jt5.jlpt5_null = 0
ORDER BY RAND())
GROUP BY e.entry
ORDER BY RAND()
LIMIT 20
答案 1 :(得分:0)
您可以使用此解决方案 -
SELECT e.ent_seq,
GROUP_CONCAT(DISTINCT kei.keb SEPARATOR'; ')AS kebs,
GROUP_CONCAT(DISTINCT rei.reb SEPARATOR '; ') AS rebs,
GROUP_CONCAT(DISTINCT sei.mean SEPARATOR '; ') AS means,
FROM (SELECT * FROM entry ORDER BY RAND() LIMIT 1) e
LEFT JOIN k_ele kei ON e.entry = kei.entry
LEFT JOIN r_ele rei ON e.entry = rei.entry
LEFT JOIN sense se ON e.entry = se.entry
LEFT JOIN s_gloss_eng sei ON se.SID = sei.SID
WHERE mn_null = 1
GROUP BY e.entry
如果WHERE mn_null = 1
是e
表中的字段,则将条件mn_null
添加到entry
表别名。