0

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 !

Edited by newdave: n/a

2
Contributors
2
Replies
3
Views
7 Years
Discussion Span
Last Post by drjohn
1

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

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.