当前位置:Gxlcms > 数据库问题 > mysql select

mysql select

时间:2021-07-01 10:21:17 帮助过:7人阅读

a、b两列都相同才视为相同

 

select concat( rtrim(a), ‘ (‘, b, ‘)‘ ) as c 连接、去空格、别名

 

select a*b + - * /

 

子查询

子查询作为where条件,多与in配合使用,也可以和=或<>配合使用

where a in (select a from t where b=3) as t2;

 

 

子查询作为计算字段

select cname, (select count(*)

from orders

where orders.cid=customers.cid) as orders

from customers;

 

子查询作为from字段

select a from (select ...) temp //不加别名报错

 

 

union

列必须相同,但次序可以不同

列数据类型必须兼容,可以隐式转换

order by只能在最后一个select后面出现一次,对全部数据排序

 

select a from t where a>2

union

select a from t where a<6

 

若存在1行a=3,只会被返回一次,union会自动去重

union all 返回所有行

 

select省略from,可用来处理表达式:select 3*2、select now() 等

 

mysql select

标签:des   自动   select   mysql   nbsp   mys   不同   font   order   

人气教程排行