Ive got a rather complicated query Im running, and before I change a table structure and rewrite some other files I was wondering if anyone could tell me if this is possible.
SELECT
DISTINCT(users.user_id),
(resi.curr_state WHERE resi.user_id = "users.user_id") AS current_state
FROM
ci_users AS users, ci_residents AS resi .....
WHERE stuff HAVING current_state = '".$php_variable_ill_use."'
Im happy to share more code if necessary, but my main question here is can I do that first as statement before the from or even after if it will work.
Something like this might work: