Probably count the resulting rows and make sure it matches the count of the in
, in this case that count would be 2 as you're checking for 2 different values. This logic is assuming id is your primary key. In mysql_*, there's a mysql_num_rows function you can use.
But please move away from the mysql_* extension function, since this extension is no longer maintained and removed as of PHP 7. An easy transition would be to the mysqli_* functions which work very similar to the mysql_* functions. If you move over to an ORM, library, or framework etc, you'll most likely move over to PDO. One of the benefits of moving over is having support for prepared queries so you're resistant against sql injection, because user input won't be able to alter the query's structure being ran, only the input sent to it.
Please see the mysqli equivalent:
https://www.php.net/manual/en/mysqli-result.num-rows.php
You might also consider altering the query and wrapping the select into a count like so:
SELECT count(id) as 'count' FROM `bokningar_bokat` WHERE `id` IN ('255','244')
you can also use count(*)
which works basically the same. One of the advantages of this is that even if no matches are found, the query would still give you a result. Otherwise you'd need to check the number of resulting rows returned.
Finally you can get a bit fancy with for example:
SELECT (count(`id`) = 2) as 'foundAll' FROM `bokningar_bokat` WHERE `id` IN ('255','244')
Then foundAll will be either 1 or 0, depending upon if it found all the ids or not.
This sort of code can get messy pretty quick.
If your list is small, it might make sense to just pull all the matching records, and do the looping and counting logic within PHP itself.
See also:
https://dba.stackexchange.com/questions/211355/how-to-check-if-all-elements-of-an-array-exists-in-a-table