• 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
  • 相关阅读:
    delphi 相对路径
    delphi 安装.dpk;package
    SVN Unable to connect to a repository at UR
    android oncreate获取宽高度
    android 中Activity的onStart()和onResume()的区别是什么
    android canvas d
    android Bitmap类方法属性 详细说明
    android 读取根目录下的文件或文件夹
    Android UI编程(1)——九宫格(GridView)
    Android程序函数 将assets文件夹下的文件复制到手机的sd卡中(包括子文件夹)
  • 原文地址:https://www.cnblogs.com/cf924823/p/4869526.html
Copyright © 2020-2023  润新知