I have a SELECT query where you search by car owners.
Every owner can have more than one car.
There is random generated list of cars of which we have to find owners.
...
$owners[] = $dbaseowners["ownerid"] // owner ID's fetched from database
$owners = implode (',',$owners);
SELECT carname FROM cars WHERE ownerid IN ($owners);
My problem is when one owner is used more than once for example: IN (1,1,4,1) – mysql only fetch one ‘copy’ of this owner’s data.
Since i have a randomly generated car list, I have to have owner row for every car no matter if owner is the same.
Any ideas?
I believe you have to revise your design and have a join table to relate the owners to cars. Having 1,1,4,1 in one row of table is not compliant with the first normal form and you should avoid using it.