您的位置:首页 > 数据库 > MySQL

mysql 复杂sql

2016-05-09 23:04 567 查看
mysql

1 将一张表中的数据复制到另一张表中 (一张表更新另一张表)

update class c ,salay s set c.salay = s.salay where c.menuId = s.menuId

update class c ,salay s set c.salay = s.salay ,c.name=s.name where c.menuId = s.menuId

2 将一张表中的数据复制到另一张表中(完全复制)

insert into table1 select * from table2

3 有则更新,无则插入

REPLACE salay1(menuId,salay) values("44","dd")

4 多个字段进行拼接

update hyz set date_proofNo = concat(date,'_',proofNo)

5 将一个String类型转换为日期进行比较

select * from test 2

where str_to_date(date,'%m/%d/%y') between str_to_date('02/03/2015','%m/%d/%y'))

and str_to_date('03/31/2015','%m/%d/%y')

6 分页查询 (从第10个开发,20条数据)

select * from test

order by id asc

limit 10,20

7 mysql 远程授权

GRANT ALL PRIVILEGES ON *.* TO 'myuser'@'%' IDENTIFIED BY 'mypassword' WITH GRANT OPTION;
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: