0

如何检查一个值是否存在于前 1000 行中,以及它是否返回信息。

就像是

select cme_fbid 
from table1 if exists(select cme_fbid from table1 limit 1000)
4

4 回答 4

1

使用子查询来限制您查看的数据:

select cme_fbid 
from (select * from table1 order by someThing limit 1000) x
where someField = someValue
于 2012-10-28T10:37:12.393 回答
1
SELECT
    CASE 
        WHEN EXISTS(SELECT cme_fbid FROM table1 LIMIT 1000) THEN t.cme_fbid
        ELSE NULL
    END
    FROM table1 t
于 2012-10-28T10:26:18.133 回答
1
select cme_fbid 
from table1
where cme_fbid in (
    select cme_fbid
    from table1
    limit 1000)

您可能希望向order by内部查询添加一个以获得一致/有意义的结果。

于 2012-10-28T10:32:29.443 回答
0

select count(*) as cnt from table1 where cme_fbid is not null and cme_fbid <> 0 limit 1000 order by id

mysql_row_count使用

select cme_fbid from table1 where cme_fbid is not null and cme_fbid <> 0 limit 1000 order by id

于 2012-10-28T10:23:17.710 回答