码迷,mamicode.com
首页 > 其他好文 > 详细

从另一张表读取(部分、全部)字段

时间:2015-10-23 18:46:04      阅读:146      评论:0      收藏:0      [点我收藏+]

标签:

/*部分字段*/

--create a permission (CUSTOMER_SETTINGS_EDIT) and assigned to admin role
insert into role_permissions(role_ID,permissions) select id ,‘CUSTOMER_SETTINGS_EDIT‘ as permissions from role where name=‘ADMIN‘;

 

/*全部字段*/

INSERT INTO applicationsettings (name, prefixlower, prefixupper, productbarcodeenabled, productshelflifeenabled, productiondateenabled)
SELECT  c.name, c.prefixlower, c.prefixupper, c.productbarcodeenabled, c.productshelflifeenabled, c.productiondateenabled
FROM customersettings c;

/*多个记录,多表查询*/

UPDATE role_permissions
INNER JOIN permission ON permission.id = role_permissions.permissions_ID
SET role_permissions.permissions = permission.name;

从另一张表读取(部分、全部)字段

标签:

原文地址:http://www.cnblogs.com/ly-radiata/p/4905278.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!