1222 The used SELECT statements have a different number of columns
Morning all
I have a UNION ALL problem.
If I use
select p.products_image
from DB1.shop_products p
where p.products_status = '1'
and MONTH(p.products_date_available)='11'
and YEAR(p.products_date_available)='2010'
UNION ALL
select p.products_image
from DB2.shop_products p
where p.products_status = '1'
and MONTH(p.products_date_available)='11'
and YEAR(p.products_date_available)='2010'
Then I get the records I expect.
If I use
select p.products_id,p.products_image
from DB1.shop_products p
where p.products_status = '1'
and MONTH(p.products_date_available)='11'
and YEAR(p.products_date_available)='2010'
UNION ALL
select p.products_id,p.products_image
from DB2.shop_products p
where p.products_status = '1'
and MONTH(p.products_date_available)='11'
and YEAR(p.products_date_available)='2010'
Then I get 1222 The used SELECT statements have a different number of columns
PHP Version : 5.1.6 (Zend: 2.1.0)
MySQL Version : 4.1.21-standard-log
(Both databases are on the same server but belong to different users - I am being asked to combine the output on one of the domains.)
If I run either query in phpmyadmin then they work as expected, I'm only seeing this when I use the queries on a webpage.
Just to be clear, both databases exist, the user has access to both databases and the tables I am selecting on have an identical structure (and identical content at the moment - that will be changing hence the need for this query to work)
Thanks in advance
Subject
Written By
Posted
1222 The used SELECT statements have a different number of columns
November 05, 2010 03:13AM
November 06, 2010 11:18AM
Sorry, you can't reply to this topic. It has been closed.
Content reproduced on this site is the property of the respective copyright holders.
It is not reviewed in advance by Oracle and does not necessarily represent the opinion
of Oracle or any other party.