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 は int です。

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 = 1を追加します。emn_nullentry

于 2013-02-14T07:56:36.753 に答える