• 数据库查询


    普通查询分:

    普通查询(select 列,列 from 表名)

    条件查询(where 列), 单条件_并列条件_或条件

    模糊查询(where 列 like'内容%'),

    统计查询(count(主键)/max(列)/min(列)/avg(列)/sum(列)),  各组之间用逗号隔开

    排序查询(order by 列 desc),

    分组查询(group by 列),

    分页查询(limit (n-1)*x , x)

    高级查询分:查询多个表

    连接查询 (对列的扩展 / 相同的列要加表名,不同的列不用加表名)

          形式1: select*from 表1,表2  where  表1.列0 = 表2.列0 

          形式2: select*from 表1  join 表2  on  表1.列0 = 表2.列0

    联合查询(对行的扩展)

         select*from info where nation = 'n001'   union   select*from info where code = 'p003'

    无关子查询( 外查询不引导内查询 )

          select*from Info where nation = ( select code from Nation where name='汉族')

          select*from Info where nation in ( select code from Nation where name='汉族' or name='回族')    //多条件时用 in 不用=

    相关子查询 ( 外查询引导内查询 )

          select*from car b where b.oil<(select avg(a.oil) from car a where a.brand = b.brand)    //查询同一系列的油耗比平均油耗低的汽车信息,

  • 相关阅读:
    HDU 4825 Xor Sum
    Linux下使用Crontab定时执行脚本
    HDU 4824 Disk Schedule
    Educational Codeforces Round 26 D. Round Subset 动态规划
    POJ 1833 排列
    HDU 1716 全排列
    HDU 1027 全排列
    Educational Codeforces Round 26 A C 之Python
    ACM输入输出之python
    标准C程序设计七---102
  • 原文地址:https://www.cnblogs.com/hellodp/p/5272194.html
Copyright © 2020-2023  润新知