开发者

How to rephrase MySQL query with when `IN` seems not allowed?

This MySQL-Query:

SELECT * FROM table_1 t_1
WHERE t_1.title_search IN
(
  SELECT title_search FROM t_2 limit 1, 10
);

produces this error:

Error Code: 1235. This version of MySQL doesn't yet support 'LIMIT & IN/ALL/ANY/SOME subquery'

After some googling I found mysqlf on this Developer 开发者_开发百科Page of MySQL. I understand, that this form of query is not supported. Is there a way to rephrase this?


SELECT t_1.* 
FROM table_1 t_1, table_2 t_2
WHERE t_1.title_search = t_2.title_search
limit 1,10;

If you're using the limit for, say a web paging, then the limit is best the last clause, if however you are using limit to restrict the results from the IN clause (you actually only want to match on the first 10 records of the T_2 table), then the above is not correct.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜