转换时间格式 查询的语句:
select FROM_UNIXTIME(add_time, '%Y年%m月%d' ) from sto_plu_vote_log
where add_time > UNIX_TIMESTAMP('2015-09-20');
查询存在共同某一字段(单号)的语句:
select* from test where name in
(selectname from test group by name having COUNT(*)>1)
字段替换语句:
update 表 set 内容字段=replace(内容字段,'h3','h2') h3换成h2
update table set a= 'a'
insert into table(a,b) values('a','b')
修改关联标的某字段
update table set a=table2.a from table2 where table.id=table2.member_id
insert into 复制表数据
1.INSERT INTO SELECT语句
语句形式为:Insert into Table2(field1,field2,...) select value1,value2,... from Table1
要求目标表Table2必须存在,由于目标表Table2已经存在,所以我们除了插入源表Table1的字段外,还可以插入常量。
2.SELECT INTO FROM语句
语句形式为:SELECT vale1, value2 into Table2 from Table1
要求目标表Table2不存在,因为在插入时会自动创建表Table2,并将Table1中指定字段数据复制到Table2中。
select count(*) from vote_log group by works_id