Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
424 views
in Technique[技术] by (71.8m points)

如何一条SQL从一张表中取出关联字段值分别为A/B/C的数据一个取出N条?

如何一条SQL从一张表中取出关联字段值分别为A/B/C的数据一个取出N条?


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

自问自答

SELECT * FROM s_area AS a
WHERE area_parent_id in (3,4,5) and 5 > ( SELECT COUNT(*) FROM s_area WHERE area_parent_id = a.area_parent_id AND area_id>a.area_id) 
order by area_sort asc

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...