且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

MySQL:将另一个表中的值插入一列

更新时间:2022-02-09 23:43:32

您可以在 SELECT 列列表中使用表达式.只要选择列表中的列和目标表中的列在数量和数据类型上匹配,您就可以执行以下操作:

You can use expressions in your SELECT column-list. As long as the columns in the select-list and the columns in the destination table match in number and data type, you can do something like this:

INSERT INTO items_rooms (item_id, room_id, x_dot_y, n)  
SELECT id, room_id, CONCAT(x,'.',y), z
  FROM `items_phoenix`