1.SELECT count( * ) FROM `feed` WHERE `uid` =1121293
可以返回符合条件记录的总数
2.SELECT * FROM `feed` WHERE `uid` =1121293 limit 1
可以返回一条记录的字段内容
3.SELECT EXISTS(SELECT * FROM `feed` WHERE `uid` =1121293)
只能判断是否存在记录,子查询中的SELECT *在执行时会被忽略掉。
以上三种方法一般认为第三种是效率最高的。
参考资料
http://stackoverflow.com/questions/1676551/best-way-to-test-if-a-row-exists-in-a-mysql-table
http://stackoverflow.com/questions/9026184/an-efficient-way-to-test-if-a-table-row-exists
http://dev.mysql.com/doc/refman/5.0/en/exists-and-not-exists-subqueries.html