D
D
Dmitry2014-05-03 17:07:46
PHP
Dmitry, 2014-05-03 17:07:46

What is the best way to check if a record exists in a database?

There are databases. users table. There is registration. What is the fastest and easiest way to check for the presence of the e-mail or username that was entered during registration, for the presence of it in the database?
Is it enough to just make a selection based on the entered e-mail/username, count the number of rows received, and if it is not equal to 0, then terminate the function?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Anarchist, 2014-05-13
@another_dream

SELECT true FROM users WHERE name = ? OR email = ? LIMIT 1;

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question