Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/algorithm/10.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Mysql 为什么在查看选择查询时收到带有WHERE子句的“未知列'xyz'”?_Mysql_Sql_Select_View_Where Clause - Fatal编程技术网

Mysql 为什么在查看选择查询时收到带有WHERE子句的“未知列'xyz'”?

Mysql 为什么在查看选择查询时收到带有WHERE子句的“未知列'xyz'”?,mysql,sql,select,view,where-clause,Mysql,Sql,Select,View,Where Clause,MySQL数据库社区版本:5.6.27,Windows 7 Pro x64 我刚刚创建了这个视图: DELIMITER $$ ALTER ALGORITHM=UNDEFINED DEFINER=`admin`@`%` SQL SECURITY DEFINER VIEW `vw_qb_assembly_component_info` AS ( SELECT `qb_assembly_components`.`assembly_item_id` AS `assemblyId`, `ai

MySQL数据库社区版本:5.6.27,Windows 7 Pro x64

我刚刚创建了这个视图:

DELIMITER $$

ALTER ALGORITHM=UNDEFINED DEFINER=`admin`@`%` SQL SECURITY DEFINER VIEW `vw_qb_assembly_component_info` AS (
SELECT
  `qb_assembly_components`.`assembly_item_id`   AS `assemblyId`,
  `ai`.`name`                                   AS `assemblyName`,
  `qb_assembly_components`.`component_quantity` AS `componentQuantity`,
  `qb_assembly_components`.`component_item_id`  AS `item_id`,
  `ci`.`name`                                   AS `name`,
  `ci`.`item_number_type`                       AS `item_number_type`,
  `ci`.`type`                                   AS `type`

FROM ((`qb_assembly_components`
    JOIN `qb_items` `ai`
      ON ((`ai`.`item_id` = `qb_assembly_components`.`assembly_item_id`)))
   JOIN `qb_items` `ci`
     ON ((`ci`.`item_id` = `qb_assembly_components`.`component_item_id`))))$$

DELIMITER ;
我正在尝试查询视图中具有特定qb_assembly_components.assembly_item_id值的行。我尝试了几种在WHERE子句中定义列的变体,但始终收到错误:

“where子句”中的未知列“xyz”

以下是我尝试过的版本:

WHERE `qb_assembly_components`.`assemblyId` = 'RR-0T056'
WHERE `qb_assembly_components`.`assembly_item_id` = 'RR-0T056'
WHERE `assemblyId` = 'RR-0T056'
我被难住了。我在谷歌上搜索了一下,发现了一些结果,似乎表明使用别名是我在上述3个示例中的最后一个示例的方法,但它不起作用

我做错了什么?

如果您从视图VW\u qb\u assembly\u component\u info中选择``

然后where子句应该引用视图名,而不是原始表名

WHERE `vw_qb_assembly_component_info`.`assemblyId` = 'RR-0T056'
如果您是从VIEWvw_qb_assembly_component_info中选择的``

然后where子句应该引用视图名,而不是原始表名

WHERE `vw_qb_assembly_component_info`.`assemblyId` = 'RR-0T056'