This is the problem – how do I make the following work WITHOUT using UNION or a second select query?
Code:
$query = "SELECT DISTINCT(t.tid), IF(last_job2 <= 2000, last_job2, last_job) AS last_job
FROM smf_posts p
LEFT JOIN smf_topics t ON (p.topic_id=t.tid)"
So that when I add in the WHERE statements it can recognize the if / as of last_job?
For instance in the WHERE below
WHERE last_job < 2000
In other words, I want this “IF(last_job2 <= 2000, last_job2, last_job) AS last_job”
to be recognized by the time it reaches “WHERE last_job < 2000”. With my current code it does not follow “IF(last_job2 <= 2000, last_job2, last_job) AS last_job”.
Thanks!
Just a wild guess. Do you want this?:
or perhaps this: