pedro mpa wrote:
Greetings.

I need help on the following query.
I get an error like "Unknown/Invalid column total_price [...]" when I try
filter by total_price.
How can I do this correctly?

SELECT receipts.*, (SELECT SUM(receipt_itens.price) FROM receipt_itens WHERE
        receipt_itens.id_receipt=receipts.id) AS total_price
FROM receipts WHERE total_price >= ".$minprice." " AND total_price <= ".$maxprice." "
        ORDER BY receipts.date DESC

Thanks in advance.

Pedro.

You can't use column aliases in the WHERE clause.  Try changing "WHERE" to 
"HAVING".

Michael

--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:    http://lists.mysql.com/[EMAIL PROTECTED]

Reply via email to