mysql> select job_desc_title from postings where id=194582;
+-----------------------------+ | job_desc_title | +-----------------------------+ | Speech/Language Pathologist | +-----------------------------+ 1 row in set (0.00 sec)
mysql> select email_address,first_name,last_name,home_phone_area,home_phone_num from accounts
-> left join profiles on profiles.account_id=accounts.id
-> where accounts.id=5;
+--------------------+------------+-----------+-----------------+----------------+ | email_address | first_name | last_name | home_phone_area | home_phone_num | +--------------------+------------+-----------+-----------------+----------------+ | [email protected] | Jianhua | He | 425 | 3584396 | +--------------------+------------+-----------+-----------------+----------------+ 1 row in set (0.00 sec)
我需要工會的上述2個查詢,但我試失敗:mysql的工會問題
mysql> select job_desc_title from postings where id=194582
-> union all
-> select email_address,first_name,last_name,home_phone_area,home_phone_num from accounts
-> left join profiles on profiles.account_id=accounts.id
-> where accounts.id=5;
ERROR 1222(21000):在使用SELECT報表具有不同的列數
什麼是做這份工作的正確版本?
我想明白爲什麼你需要聯合這些查詢?由此產生的數據與其他數據幾乎沒有關係。 也許有更好的問題要問或在這裏回答? – 2009-05-26 19:41:10
我想我正在試着像Eric那樣說下面的東西。這看起來應該加入,而不是聯合。 – 2009-05-26 19:48:49