MySQL left join problem

dude, you snuck that in there!!

the last time i saw the WHERE clause it was only testing the active column

how was i supposed to diagnose a problem without seeing either the error message or even the correct query

???

:goof:

r937: so there is no way for me to order this query by “website_visitors”?

You can’t use a column alias in a WHERE clause, you’d have to refer to your calculation again or move it to the HAVING clause where you can use the alias.

Ok, im running this query in phpMyadmin and I get the below error.


SELECT UNIX_TIMESTAMP( dt_auctions.end_date ) - UNIX_TIMESTAMP( ) AS time_left, COALESCE( SUM( dt_parked_stats.uniques ) , 0 ) AS website_visitors, dt_currencies.symbol, dt_auctions.end_date, dt_auctions.paid_auction, dt_auctions.high_bid, dt_domains.id, dt_domains.domain, dt_domains.bin_price, dt_domains.minimum_offer, dt_domains.views, dt_domains.previous_offers, dt_domains.currency
FROM dt_domains
INNER JOIN dt_currencies ON dt_currencies.code = dt_domains.currency
LEFT OUTER JOIN dt_auctions ON dt_auctions.domain_id = dt_domains.id
LEFT OUTER JOIN dt_parked_stats ON dt_parked_stats.domain = dt_domains.domain
WHERE dt_domains.active = '1'
AND website_visitors
BETWEEN 0
AND 1000
GROUP BY dt_domains.id
ORDER BY dt_domains.domain ASC
LIMIT 0 , 30

#1054 - Unknown column ‘website_visitors’ in ‘where clause’