Fastest way to determine if record exists

前端 未结 11 1169
清歌不尽
清歌不尽 2020-11-29 16:16

As the title suggests... I\'m trying to figure out the fastest way with the least overhead to determine if a record exists in a table or not.

Sample query:

11条回答
  •  萌比男神i
    2020-11-29 17:02

    Below is the simplest and fastest way to determine if a record exists in database or not Good thing is it works in all Relational DB's

    SELECT distinct 1 products.id FROM products WHERE products.id = ?;
    

提交回复
热议问题