MYSQL在一个字段值后面加字符串,如下: member 表名 card 字段名 update member SET card = '00' || card; (postgreSQL 用 || 来连贯字符串) MySQL连贯字符串不能利用加号(+),而利用concat. 比方在aa表的name字段前加字符'x',利用: update aa set name=concat('x',name)…
复制表结构 CREATE TABLE 新表 SELECT * FROM 旧表 where 1=2 复制表结构和数据CREATE TABLE 新表 SELECT * FROM 旧表 查询重复数据: select user_name,count(*) as count from user_table group by user_name having count>1; 比较日期,转换成时间戳UNIX_TIMESTAMP() select * from Table where UNIX_TIMESTA…
mysql的sql语句优化方法面试题总结 不要写一些没有意义的查询,如需要生成一个空表结构: select col1,col2 into #t from t where 1=0 这类代码不会返回任何结果集,但是会消耗系统资源的,应改成这样: create table #t(...) 很多时候用 exists 代替 in 是一个好的选择: select num from a where num in(select num from b) 用下面的语句替换: select num from a wh…