mysql - 使用 mysql 从其他表中选择插入

标签 mysql

尝试使用以下命令插入其他表,但既不抛出错误也不插入:

INSERT INTO orderlines(orderLineItemName,orderLineItemnotes,itemID,itemPriceNormal,categoryID
,regionID,orderLineItemQuantity,orderLineItemPriceUnit,orderLineItemDiscount,orderLineItemSubTotal,
orderLineItemTotalTax 
,orderLineItemStatus,userID,orderLineItemDateCreated,orderLineItemDateUpdated,ordercode) 
SELECT quoteLineItemName, quoteLineItemnotes, itemID, itemPriceNormal, categoryID, regionID, 
quoteLineItemQuantity, quoteLineItemPriceUnit, quoteLineItemDiscount, quoteLineItemSubTotal, 
quoteLineItemTotalTax, quoteLineItemStatus, userID, quoteLineItemDateCreated, quoteLineItemDateUpdated,
'Complete' as orderstatus 
FROM quoteslines 
WHERE quotelineitemid = 1

最佳答案

试试这个

INSERT INTO orderlines
SELECT quoteLineItemName, quoteLineItemnotes, itemID, itemPriceNormal, categoryID, regionID, 
quoteLineItemQuantity, quoteLineItemPriceUnit, quoteLineItemDiscount, quoteLineItemSubTotal, 
quoteLineItemTotalTax, quoteLineItemStatus, userID, quoteLineItemDateCreated,              quoteLineItemDateUpdated,
 'Complete' as orderstatus 
FROM quoteslines 
WHERE quotelineitemid = 1 

关于mysql - 使用 mysql 从其他表中选择插入,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27758264/

相关文章:

java - 使用 JDBC 驱动程序将 CJK 表单提交到 MySQL

mysql - Rails has_and_belongs_to 与主键删除销毁时的所有记录

php - Laravel 连接表不返回任何数据

python - 使用 django 和 sqlalchemy 但后端 mysql

python - sqlite - 使用两列的倍数的 WHERE 语句

php - 从 PHP 添加到数据库插入 NULL

mysql - 将多行合并为一列

Windows 的 Mysql 调优/性能

java - 无法使用 Struts 将文件上传到 MySQL

php - 在 Laravel 中使用原始 MySql 语句创建外键