A
A
Adik Izat2020-05-06 03:55:43
MySQL
Adik Izat, 2020-05-06 03:55:43

Why does an empty query return all rows?

How can I fix the query so that when the query is empty, rows with verified = 1 and deleted = null are returned? Now returns all rows. Even where verified = null and deleted = 1.

SELECT * FROM `injureds` WHERE `verified` = 1 AND `deleted` IS NULL AND `id` LIKE CONCAT('%%') OR `iname` LIKE CONCAT('%%');

Answer the question

In order to leave comments, you need to log in

1 answer(s)
I
Immortal_pony, 2020-05-06
@JaxAdam

Put brackets:

SELECT 
    * 
FROM 
    `injureds` 
WHERE 
    `verified` = 1 AND 
    `deleted` IS NULL AND  (
        `id` LIKE CONCAT('%%') OR 
        `iname` LIKE CONCAT('%%')
    );

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question