标签: mysql sql
学习SQL。加入两个表后如何随机抽取样本?非常感谢。
select * from t1 left join t2 on t1.ID = t2.ID
答案 0 :(得分:2)
只需添加ORDER BY rand()和LIMIT样本大小(例如5):
ORDER BY rand()
LIMIT
select * from t1 left join t2 on t1.ID = t2.ID ORDER BY rand() LIMIT 5