由于列名错误,SQL查询无法正常工作,但列存在

时间:2015-11-30 10:26:12

标签: mysql sql innodb myisam

我遇到以下查询的问题:

SELECT *
FROM `pageindex`
    FULL JOIN `pages` ON `pageindex`.`url` = `pages`.`page`
WHERE `pageindex`.`url` IS NULL;

我也试过这个:

SELECT *
FROM pageindex
    FULL JOIN pages ON pageindex.url = pages.page
WHERE pageindex.url IS NULL;

我收到此错误:

ERROR 1054 (42S22): Unknown column 'pageindex.url' in 'where clause'

但是我不明白为什么,当列确实存在时,这里是表中的列:

+--------------+--------------+------+-----+---------+-------+
| Field        | Type         | Null | Key | Default | Extra |
+--------------+--------------+------+-----+---------+-------+
| url          | varchar(255) | NO   | PRI | NULL    |       |
| title        | varchar(255) | YES  | MUL | NULL    |       |
| keywords     | text         | YES  |     | NULL    |       |
| description  | text         | YES  |     | NULL    |       |
| last_updated | date         | YES  |     | NULL    |       |
| heading      | varchar(255) | YES  |     | NULL    |       |
| textcontent  | text         | YES  |     | NULL    |       |
| htmlcontent  | text         | YES  |     | NULL    |       |
| audiencetype | varchar(255) | YES  |     | NULL    |       |
+--------------+--------------+------+-----+---------+-------+

希望你能提供帮助,

由于

1 个答案:

答案 0 :(得分:2)

因为MySQL不支持FULL JOIN,所以您的查询解释如下:

SELECT *
  FROM `pageindex` AS full
  JOIN `pages` ON `pageindex`.`url` = `pages`.`page`
 WHERE `pageindex`.`url` IS NULL;