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 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 是一个整数。

4

2 回答 2

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
于 2013-02-15T14:01:59.100 回答
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 = 1e表别名添加条件。mn_nullentry

于 2013-02-14T07:56:36.753 回答