SQL

MySQL复合语句用法

update和select联用, 将advid=2记录的数据同步更新到advid=14 update advertisement A inner join advertisement B set A.title = B.title, A.targets = B.targets, A.parameters= B.parameters, A.code = B.code where A.advid=14 and B.advid=2 insert和select联用, 将advid=4记录的数据拷贝出来,定义type字段为xxx,作为新纪录插入 INSERT INTO advertisement (available, type,displayorder, title, targets,parameters, code,starttime,endtime) SELECT available, "xxxx" as "type",displayorder, title, targets,parameters, code,starttime,endtime FROM advertisement WHERE advid = 4