hello, I need to have in ONE request clients who just like apple AND banana :

clients
id
name

relations_like
id
id_client
id_like

like_fruits
id
title

a same client can have a few differents like_fruits
if I made a classic
SELECT FROM relations_like WHERE id_like IN (idapple, idbanana)

I will have all clients who like apple OR banana
but I want only clients who like the two together : the ones who like apple AND banana, so for example I offer them special apple/banana juice :)
of course id_like=idapple AND id_like=idbanana shows nothing, and id_like=idapple OR id_like=idbanana doesn't help

any idea ? do i need to imbricate selects ?
I suppose it must be a classic issue but can't find anything, certainly because I don't what are good technic terms ;)

think to you !

response from Guelphdad :

SELECT FROM relations_like WHERE id_like IN (idapple, idbanana)
group by
id_client
having count(*)=2

perfect with dynamic count(x) with the number of fruits

SELECT from relations_like
WHERE id_like = idapple
AND id_like = idbanana

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.