in-subquery

What's wrong with this MySQL query? SELECT * AS `x`, how to use x again later?

The following MySQL query: select `userID` as uID, (select `siteID` from `users` where `userID` = uID) as `sID`, from `actions` where `sID` in (select `siteID` from `sites` where `foo` = "bar") order by `timestamp` desc limit 100 …returns an error: Unknown column 'sID' in 'IN/ALL/ANY subquery' I don't understand what I'm doing wron...

Is there a better way to write this SQL than using WHERE ... IN (subquery)?

is there a better way to write this SQL than using WHERE ... IN (subquery)? SELECT device.mac, reseller.name, agent.name FROM device LEFT JOIN global_user ON device.global_user_id = global_user.id LEFT JOIN agent ON global_user.id = agent.global_user_id LEFT JOIN reseller ON global_user.id = reseller.global_user_id...

MySQL Subquery Causing Server to Hang

I'm trying to execute the following query SELECT * FROM person WHERE id IN ( SELECT user_id FROM participation WHERE activity_id = '1' AND application_id = '1' ) The outer query returns about 4000 responses whilst the inner returns 29. When executed on my web server nothing ha...

LINQ subquery IN

Hi ! I'm a newbie with the IQueryable, lambda expressions, and LINQ in general. I would like to put a subquery in a where clause like this : Sample code : SELECT * FROM CLIENT c WHERE c.ETAT IN ( SELECT DDV_COLUMN_VAL FROM DATA_DICT_VAL WHERE TBI_TABLE_NAME = 'CLIENT' AND DD_COLUMN_NAME = 'STATUS' AND DDV_COLUMN_VAL_LANG_...

SQL subquery matches hard-coded IN criteria, but not subquery

I have a group of people who have taken a test. I can select their IDs with this query: SELECT person_id FROM tests WHERE test_code = 1234 I'd like to pull these individuals' records from a demographics table, so I tried this subquery to do so: SELECT * FROM demographics d WHERE d.person_id IN ( SELECT t.person_id FROM tests...