我有这样的桌子
id | eventid | category | type
----+------------+------------+------
1 | 1 | music | event
2 | 2 | music | event
3 | 3 | music | event
4 | 4 | music | event
5 | 5 | music | page
6 | 6 | music | page
现在我需要获取 4 条记录的数据,其中 2 条来自带有状态事件的表,2 条来自带有状态页面的表
例子:
id | eventid | category | type
----+------------+------------+------
1 | 1 | music | event
2 | 2 | music | event
5 | 5 | music | page
6 | 6 | music | page
我已尝试使用以下查询,但出现错误
SELECT *
FROM event_subcategory
WHERE category = 'music'
AND TYPE = 'event'
LIMIT 2
UNION
SELECT *
FROM event_subcategory
WHERE TYPE = 'page'
LIMIT 2