select id,mobile,realname as name,weixin as message_note,address_des as address,create_time,cateid from v1_user UNION ALL select id,mobile,name,message_note,address,create_time,cateid from v1_clue 首先要将字段整成一样,然后使用 UNION ALL 联合. 注意:UNION在进行表链接后会去重,UNI
个人平时记录的,有点乱 1.修改时间字段,如果时间字段的类型是date或者是datetime类型的 update 表名 set 时间字段 = DATE_FORMAT(NOW(),'%Y-%m-%d %H:%i:%s') where id = 110 2.查询时间格式为date或者datetime类型的数据,用时间做条件的 select * from 表名 where date_format(时间字段,'%Y-%m-%d') = '2016-12-10' 3.替换某个字段中的指定字符或数据 upd
mysql 删除单表内多个字段重复的数据 DELETE from lot_log_payflow WHERE (pay_no,sub_flow_type) in () s1) AND id ) s2); 查询重复的数据 select * from lot_log_payflow WHERE (pay_no,sub_flow_type) in () s1) AND id ) s2) order by create_time asc; 删除单个字段重复数据 DELETE from lot_order
需要修改数据表名或者修改数据表字段时,就需要使用到MySQL ALTER命令. 删除,添加或修改表字段 如下命令使用了 ALTER 命令及 DROP 子句来删除表的 i 字段: ALTER TABLE testalter_tbl DROP i; 如果数据表中只剩余一个字段则无法使用DROP来删除字段. MySQL 中使用 ADD 子句来向数据表中添加列,如下实例在表 testalter_tbl 中添加 i 字段,并定义数据类型: ALTER TABLE testalter_tbl ADD i I
mysql把一个表的字段update成另一个表的字段根据id 1.填充activity表里面的creator字段,用org的founderid,其中activity的orgid要和org的id对应,具体sql语句如下:update activity a inner join (select id,founderid from org o) c on a.orgid =c.id set a.creator = c.founderid;
同一张表存在类似多级菜单的上下级关系的数据,查询出符合条件的某些数据的id拼接成一个字段返回: SELECT CONCAT(a.pid, ',', b.subid) AS studentIDS FROM (SELECT id as pid, sourceCode as scode FROM student WHERE studentType='父级条件1' AND studentCode='父级条件2') a LEFT JOIN (SELECT id as subid, parentCode p