an efficient way to test if a table row exists

后端 未结 5 1632
迷失自我
迷失自我 2020-12-20 04:07

I\'m trying to find the most efficient way to determine if a table row exists.

I have in mind 3 options:

  1. SELECT EXISTS(SELECT 1 FROM table1 WHERE so

5条回答
  •  轻奢々
    轻奢々 (楼主)
    2020-12-20 04:21

    The exists function is defined generally in SQL, it isn't only as a MySQL function : http://www.techonthenet.com/sql/exists.php and I usually use this function to test if a particular row exists.

    However in Oracle I've seen many times the other approach suggested before:

    SELECT COUNT(1) FROM table 1 WHERE some_condition.
    

提交回复
热议问题