This is the syntax of a select statement as shown in the manual:
SELECT [ALL | DISTINCT] result [FROM table-list]
[WHERE expr]
[GROUP BY expr-list]
[HAVING expr]
[compound-op select]*
[ORDER BY sort-expr-list]
[LIMIT integer [( OFFSET | , ) integer]]
The bit you want is LIMIT[integer]. Say
You could do
SELECT whatever FROM table WHERE criteria LIMIT 1
or
SELECT COUNT(*) AS RowCount FROM table WHERE criteria
Then just check that the value of RowCount > 0. The nice thing about the
latter is that now you are set up if you ever want to know how many rows meet
the criteria that
Good day!
I want to retrieve only one record in the database with a condition that may
cause a retrieval of many records. The purpose of this is for me to check
only if there is at least 1 record in the database. So if given my
condition, the query would now search for one record in the database
3 matches
Mail list logo