mySQL query syntax error
am 14.11.2009 09:23:47 von Ron Piggott
I am getting the following error message:
#1054 - Unknown column 'customers.email' in 'order clause'
from the query below --- I don't understand why. Would someone help me
please? Ron
SELECT 'first_name', 'last_name', 'email'
FROM (
(
SELECT `firstname` , `lastname` , `buyer_email`
FROM `paypal_payment_info`
WHERE `datecreation` = '$two_weeks_ago'
GROUP BY `buyer_email`
)
UNION ALL (
SELECT `mail_order_address`.`first_name` ,
`mail_order_address`.`last_name` , `mail_order_address`.`email`
FROM `mail_order_address`
INNER JOIN `mail_order_payment` ON `mail_order_address`.`reference` =
`mail_order_payment`.`mail_order_address_reference`
WHERE `mail_order_payment`.`payment_received` = '$two_weeks_ago'
GROUP BY `mail_order_address`.`email`
)
) AS customers
ORDER BY `customers`.`email` ASC
--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
Re: mySQL query syntax error
am 14.11.2009 13:35:18 von Ron Piggott
--=-KwPFedJGyUtEc9eFEnCF
Content-Type: text/plain
Content-Transfer-Encoding: 7bit
I found the problem. The first subquery needed "AS" aliases. I am
learning more of what mySQL is capable of and appreciate the help. Ron
-----Original Message-----
From: TG
To: ron.piggott@actsministries.org
Subject: Re: [PHP-DB] mySQL query syntax error
Date: Sat, 14 Nov 2009 07:17:53 -0500
Only half awake and don't really see the problem with customers.email since
you alias the two selects and union as 'customers'. But since you don't
have any other tables in your primary select, you can drop the
`customers` part and just say "ORDER BY email ASC".
----- Original Message -----
From: Ron Piggott
To: PHP DB
Date: Sat, 14 Nov 2009 03:23:47 -0500
Subject: [PHP-DB] mySQL query syntax error
>
> I am getting the following error message:
>
> #1054 - Unknown column 'customers.email' in 'order clause'
>
> from the query below --- I don't understand why. Would someone help me
> please? Ron
>
>
> SELECT 'first_name', 'last_name', 'email'
> FROM (
>
> (
>
> SELECT `firstname` , `lastname` , `buyer_email`
> FROM `paypal_payment_info`
> WHERE `datecreation` = '$two_weeks_ago'
> GROUP BY `buyer_email`
> )
> UNION ALL (
>
> SELECT `mail_order_address`.`first_name` ,
> `mail_order_address`.`last_name` , `mail_order_address`.`email`
> FROM `mail_order_address`
> INNER JOIN `mail_order_payment` ON `mail_order_address`.`reference` =
> `mail_order_payment`.`mail_order_address_reference`
> WHERE `mail_order_payment`.`payment_received` = '$two_weeks_ago'
> GROUP BY `mail_order_address`.`email`
> )
> ) AS customers
> ORDER BY `customers`.`email` ASC
>
>
>
> --
> PHP Database Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
--=-KwPFedJGyUtEc9eFEnCF--