Mysql WHERE XXX = ZZZ AND XXX = YYY?

SELECT * FROM names n WHERE ( SELECT COUNT(*) FROM beta be WHERE b. Sport IN ('basketball', 'lacrosse') AND b. Name = n.Id ) = 2.

Thank you! The IN clause was what I was looking for and I did not know how to find it. – ccdpowell Apr 20 at 13:08 @ccdpowell: IN clause is just a handy alias for sport = 'basketball' OR sport = 'lacrosse'.

It's COUNT(*) = 2 in a subquery you've actually been looking for. – Quassnoi Apr 20 at 13:16.

You need to change the AND with an OR AND does not means: I want all kids who play basketball AND all kids who play lacrosse. What it means is I want all all kids who play both lacrosse and basketball. When using OR get used to wrapping your condition in brackets as such WHERE (beta.

Sport = 'basketball' OR beta. Sport = 'lacrosse').

WHERE BETA. SPORT = 'BASKETBALL' OR BETA. SPORT = 'LACROSSE' Note de OR, instead of AND.

These SQL tutorials might help you out too for future.

WHERE beta. Sport = 'basketball' AND beta. Sport = 'lacrosse';" this can't return any rows since you're asking for beta.

Sport to be BOTH basketball and lacrosse... Try OR... WHERE beta. Sport = 'basketball' OR beta. Sport = 'lacrosse'; You might try a subselect of both... select * from sportsTable where itemID in (select itemID from sportsTable WHERE beta.

Sport = 'basketball') and itemID in (select itemID from sportsTable WHERE beta. Sport = 'lacrosse').

I know this is the problem... If I use OR my results will include kids who play basketball and don't play lacrosse. I only want results from kids who play BOTH basketball and lacrosse. – ccdpowell Apr 20 at 12:58 see updated code above... – John K.

Apr 20 at 12:59.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions