假设有自增id
select *
from article A
where 6>(select count(*) from article B where A.category_id=B.category_id and A.id<B.id) and `category_id`
IN (
'101', '110'
)
select *
from article A
where 6>(select count(*) from article B where A.category_id=B.category_id and A.id<B.id) and `category_id`
IN (
'101', '110'
)
#1054 - Unknown column 'article.inputtime' in 'order clause'
FROM `article`
WHERE `category_id`
IN = '101'
LIMIT 0 , 30
union all
SELECT *
FROM `article`
WHERE `category_id`
IN = '110'
LIMIT 0 , 30
#1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '= '101' LIMIT 0 , 30 union all SELECT * FROM `article` WHERE `category_id' at line 4麻烦你在我看看是那里的问题
FROM `article`
WHERE `category_id`
IN = '101'
LIMIT 0 , 30 )
union all
(SELECT *
FROM `article`
WHERE `category_id`
IN = '110'
LIMIT 0 , 30 )加上括号试试
IN = '101' 后面有很多,不同的值,所以这种效率还能不能提高呢?