php - MySQL:无法在 MySQL View 中插入

标签 php mysql database view insert

我遇到了问题。我研究过但没有得到解决方案。

我正在尝试插入 mysql VIEW,但出现以下错误:

Can not modify more than one base table through a join view 'my_view'

查询:

INSERT INTO  `aosship`.`products_inventory` (

`products_id` ,
`inventory_id` ,
`parent_id` ,
`qty_on_stock` ,
`inventory_date` ,
`expiration_date` ,
`supplier_id` ,
`qty_in_back_order` ,
`location_id` ,
`product_id` ,
`tax` ,
`qty` ,
`upc` ,
`product_name` ,
`description` ,
`ebt` ,
`wic` ,
`discontinued` ,
`reorder_point` ,
`reorder_qty` ,
`taxable` ,
`time_stamp` ,
`product_control` ,
`price` ,
`catagory_name` ,
`temp_product` ,
`cost`
)
VALUES (
'00000000000',  '0',  '1',  '1',  '2014-01-18 00:00:00',  '2014-01-18',  '1',  '1',  '1',  '1',  '1',  '1',  '1',  '1',  '1',  '1',  '1',  '1',  '1',  '1',  '1',  '2014-01-18 00:00:00',  '1',  '1',  '1',  '1',  '1'
)

查询创建 View :

CREATE 
    ALGORITHM = UNDEFINED 
    DEFINER = `root`@`localhost` 
    SQL SECURITY DEFINER
VIEW `aosship`.`products_inventory` AS
    select 
        `aosship`.`products`.`ID` AS `products_id`,
        `aosship`.`inventory`.`ID` AS `inventory_id`,
        `aosship`.`inventory`.`parent_id` AS `parent_id`,
        `aosship`.`inventory`.`qty_on_stock` AS `qty_on_stock`,
        `aosship`.`inventory`.`inventory_date` AS `inventory_date`,
        `aosship`.`inventory`.`expiration_date` AS `expiration_date`,
        `aosship`.`inventory`.`supplier_id` AS `supplier_id`,
        `aosship`.`inventory`.`qty_in_back_order` AS `qty_in_back_order`,
        `aosship`.`inventory`.`location_id` AS `location_id`,
        `aosship`.`inventory`.`product_id` AS `product_id`,
        `aosship`.`inventory`.`tax` AS `tax`,
        `aosship`.`inventory`.`qty` AS `qty`,
        `aosship`.`products`.`upc` AS `upc`,
        `aosship`.`products`.`product_name` AS `product_name`,
        `aosship`.`products`.`description` AS `description`,
        `aosship`.`products`.`ebt` AS `ebt`,
        `aosship`.`products`.`wic` AS `wic`,
        `aosship`.`products`.`discontinued` AS `discontinued`,
        `aosship`.`products`.`reorder_point` AS `reorder_point`,
        `aosship`.`products`.`reorder_qty` AS `reorder_qty`,
        `aosship`.`products`.`taxable` AS `taxable`,
        `aosship`.`products`.`time_stamp` AS `time_stamp`,
        `aosship`.`products`.`product_control` AS `product_control`,
        `aosship`.`inventory`.`price` AS `price`,
        `aosship`.`inventory`.`catagory_name` AS `catagory_name`,
        `aosship`.`products`.`temp_product` AS `temp_product`,
        `aosship`.`products`.`cost` AS `cost`
    from
        (`aosship`.`inventory`
        join `aosship`.`products` ON ((`aosship`.`inventory`.`product_id` = `aosship`.`products`.`ID`)))

请指导我如何解决此问题。

非常感谢。

最佳答案

使用 VIEW,您一次只能更新一张表。

如果您想使用一个查询更新多个表,您可以查看存储过程

关于php - MySQL:无法在 MySQL View 中插入,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21200231/

相关文章:

php - MySQL:理解sql代码

php - 如何让 PHPUnit 打印内部异常?

php - 将新数据发布到数据库

PHP 多个三元运算符未按预期工作

c# - Entity Framework Core,报错Postgres violates foreign key constraint

database - Windows平台下的Redis

mysql - #1064 MySQL 错误。带有 MRG_MYISAM 引擎的 utf8_general_ci

mysql - 恢复 MySQL 数据库

mysql - 如何将选择与其自身结合起来?

mysql - 对表结构感到困惑