MySQL和Sqlserver

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/shytry/article/details/79785096

1、查询数据库中的前10条数据

SQLSERVER: select top * from table;

MYSQL:select * from table limit 10;

2、模糊查询(查询字符为‘_’)

MySQL:select * from table where table.name like '%_%'

SQLSERVER :select * from table where table.name like '%[_]%'

HIVE:select * from table where table.name like '\_'

3、sqlserver 定义变量

declare @time int;

set @time=(select convert(varchar(8),GetDate(),112));    //获取当前时间---年 月  日 返回值类型为varhcar类型

4、sqlserver类型转化

cast(indt as varchar)  //将int类型的indt 转化为varchar

5、SQLSERVER递归查询

with locs as(

select id,name,num from table where num>10 union all select A.id,A.name,A.num from table1 A, inner join locs B on A.id=B.name)

select * from locs

猜你喜欢

转载自blog.csdn.net/shytry/article/details/79785096
今日推荐