I
I
Ibishka2020-05-15 14:30:53
MySQL
Ibishka, 2020-05-15 14:30:53

Should I use LIMIT 1?

Do I need to use LIMIT 1 if, for example, it gets a post by id.

mysqli_query($connection, "SELECT * FROM `posts` WHERE `id` = '$id'");

or
mysqli_query($connection, "SELECT * FROM `posts` WHERE `id` = '$id' LIMIT 1");

Answer the question

In order to leave comments, you need to log in

1 answer(s)
E
ediboba, 2020-05-15
@Ibishka

if id is pk or it is unique then no

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question