Welcome Guest, Not a member yet? Register   Sign In
Performance boost CI3
#11

(03-06-2021, 12:32 PM)iRedds Wrote: Be careful. The proposed option can play a cruel joke with you.
This request can be written as
Code:
SELECT *
FROM table
WHERE
(id = 1 AND (d = 20 OR d = 21 OR d = 22 OR d = 25))
OR (id = 2 AND (d = 20 OR d = 21 OR d = 22 OR d = 25))
OR (id = 3 AND (d = 20 OR d = 21 OR d = 22 OR d = 25))
OR (id = 4 AND (d = 20 OR d = 21 OR d = 22 OR d = 25))
OR (id = 5 AND (d = 20 OR d = 21 OR d = 22 OR d = 25))

Depending on the logic of your database, this may conflict with the conditions.
https://www.db-fiddle.com/f/ckHvgzVN2u8a1dtv7GoNMZ/0

Perhaps you'd better use UNION
Thanks, actually in my case it is only "d" that has different values, "id" is the same inside each loop, e.g. for all 4 queries.
Reply


Messages In This Thread
Performance boost CI3 - by muuucho - 03-03-2021, 04:49 AM
RE: Performance boost CI3 - by php_rocs - 03-03-2021, 08:55 AM
RE: Performance boost CI3 - by muuucho - 03-03-2021, 11:49 AM
RE: Performance boost CI3 - by InsiteFX - 03-03-2021, 12:37 PM
RE: Performance boost CI3 - by muuucho - 03-03-2021, 12:46 PM
RE: Performance boost CI3 - by php_rocs - 03-03-2021, 02:46 PM
RE: Performance boost CI3 - by muuucho - 03-03-2021, 03:26 PM
RE: Performance boost CI3 - by php_rocs - 03-04-2021, 08:15 AM
RE: Performance boost CI3 - by muuucho - 03-06-2021, 09:29 AM
RE: Performance boost CI3 - by iRedds - 03-06-2021, 12:32 PM
RE: Performance boost CI3 - by muuucho - 03-07-2021, 04:11 AM
RE: Performance boost CI3 - by php_rocs - 03-09-2021, 09:53 AM
RE: Performance boost CI3 - by muuucho - 03-09-2021, 02:31 PM
RE: Performance boost CI3 - by php_rocs - 03-09-2021, 08:48 PM



Theme © iAndrew 2016 - Forum software by © MyBB