zoukankan      html  css  js  c++  java
  • 10.11子查询,表连接

    --数据转换

    select
    ids,code,name,brand, (cast(year(time)as varchar(10))+'' +cast(month(time)as varchar(10))+'' +cast(day(time)as varchar(10))+'')as 时间,oil,POWERS,EXHAUST,price ,pic from car select * from car where ceiling(oil)>=8.0 select * from car where ceiling(oil)>8.0 --子查询 --把查询语句查询出的结果当做一个数值使用或一组数值使用 --all所有的,any任意一个,修饰符 --in('','')在数值范围内not in()不在括号的数值范围内 select price from car where name ='宝马3系 325i 时尚型' select *from car where name like '%奥迪%'and price>=42.38 select *from car where name like '%奥迪%'and price>=(select price from car where name ='宝马3系 325i 时尚型') select *from car where name like '%奥迪%'and price>(select max(price)from car where name like'%宝马%') select *from car where name like '%奥迪%'and price>all(select price from car where name like '%宝马%' ) select *from car where name like '%奥迪%'and price>any(select price from car where name like '%宝马%' ) --in('','')在数值范围内not in()不在括号的数值范围内 == or的用法 select * from car where brand ='b001'or brand ='b002'or brand ='b003' select * from car where brand in('b001','b002','b003') select * from car where brand not in('b001','b002','b003') --表连接 (inner)join on内连接 select* from car select*from brand select code,name,brand,brand_code from car join brand on car.brand =brand .brand_code select code,name,brand,brand_code from car inner join brand on car.brand =brand .brand_code select code,name,brand,brand_code from car left join brand on car.brand =brand .brand_code select code,name,brand,brand_code from car right join brand on car.brand =brand .brand_code --子查询 select code,name,(select brand_name from brand where car.brand =brand .brand_code )as brand_name from car --表的拼接 用,笛卡尔积,类似for的穷举 select*from car,brand select*from car,brand where car.brand =brand .brand_code
  • 相关阅读:
    中国国家授时中心的时间服务器IP地址及时间同步方法
    找不到aspnet用户权限的解决方法
    unbunt下刻录光盘
    关于ubuntu 是否需要使用std::到问题。
    acm题
    IIS发生意外错误0x8ffe2740
    SQL Server Express的使用
    解决用户"sa"登录失败。该用户与可信 sql server 连接无关联。
    在CSDN上的第一篇博客
    在线求助 man page(转)
  • 原文地址:https://www.cnblogs.com/cf924823/p/4869526.html
Copyright © 2011-2022 走看看