MySQL Query with multiple LIMITS

前端 未结 5 774
甜味超标
甜味超标 2021-01-12 17:49

Let\'s say I have the following table with hundreds of toys of various colors...

---------------------------
  ITEM  |  COST  |  COLOR
----------------------         


        
5条回答
  •  暗喜
    暗喜 (楼主)
    2021-01-12 18:33

    Why not?

    select * from toys where color = 'Yellow' (LIMIT 1)
    UNION
    select * from toys where color = 'White' (LIMIT 3)
    UNION
    select * from toys where color = 'Blue' (LIMIT 2)
    

提交回复
热议问题