MySQL 一张表中两个字段值互换】的更多相关文章

update table a, table b set a.filed1= b.field2, a.field2= b.field1where a.id = b.id…
在项目开发中遇到这么一个例子,首先产品表 tb_product ----------------------------- id    name 1     手机 2    电脑 3     笔记本 第二张表 tb_product_chain(产品链) ------------------------------------------------------ int   product_id     parent_product_id 1       1                    …
sql一个表中两个字段,合并求和 SELECT SUM(字段a+'.'+字段b) as total  from TABLE…
首先描述问题,student表中有字段startID,endID.garde表中的ID需要对应student表中的startID或者student表中的endID才能查出grade表中的name字段,这时候问题就来了,如果需要一条sql一句同时查出garde表中的两条数据怎么办?(两表的关联字段为 SID) sql="select b.name,c.name as name2 from student a,garde b,grade c where a.SID=b.SID and a.SID=c…
1,为当前已有的表添加新的字段 alter table student add studentName varchar(20) not null; 2,为当前已有的表中的字段设置为主键自增 alter table student add constraint PK_studentId primaryKey(studentId); 3,为当前已有的表中的字段设置为外键 alter table student add constraint FK_teacherId_studentInfo forei…
添加字段:alter table matInformation add facid varchar(99)  default ''; 导入数据:update matInformation m set facid=(select facid from material_register v where m.partNumber=v.partNumber);(参考:https://blog.csdn.net/mar_fuck/article/details/79460571) 遇到问题:ERROR…
表A和表B,现在希望更新A表,当 A.bid = B.id时,a.x = b.x, a.y=b.y,请问mysql中sql语句 update a inner join b on a.bid=b.id set a.x=b.x,a.y=b.y ;…
现一个表中有很多字段,但我不想要其中某一个字段,手打出来字段太多,不方便. SELECT GROUP_CONCAT( column_name SEPARATOR ',' ) FROM information_schema.COLUMNS WHERE column_name <> '你不想要的字段名' AND table_name = '表名' GROUP BY table_name…
SELECT vtiger_orderitem.orderid, ( SELECT vtiger_users.last_name FROM vtiger_users WHERE vtiger_orderitem.signatory = vtiger_users.id ) AS signatory, ( SELECT vtiger_users.last_name FROM vtiger_users WHERE vtiger_orderitem.servicer = vtiger_users.id…
我有个新闻表 id,title,body,createtime,author,click 使用ef4.1 仅仅读取 id,title,createtime 并显示在页面上. public static List<NewInfo> GetHotNews() { List<NewInfo> list; list = (from n in db.NewInfoes where n.IsTop == 1 orderby n.PublishTime descending select new…