• OCP之黄伟 2


    Restricting and Sorting Data 

    Objectives

    After completing this lesson,you should be able to do the following:

    • Limit the rows that are retrieved by a query
    • Sort the rows that are retrieved by a query

    Character Strings and Dates

    列别名应当使用双引号

    字符串拼接或者日期信息,以及where子句中的数据,需要使用单引号

    • Character strings and date values are enclosed by single quotation marks
    • Character values are case-sensitive,and date values are format-sensitive.
    • The default date format is DD-MON-RR.
    SQL> SELECT last_name,job_id,department_id
      2  FROM employees
      3  WHERE last_name = 'Grant';
    
    LAST_NAME                 JOB_ID     DEPARTMENT_ID
    ------------------------- ---------- -------------
    Grant                     SH_CLERK              50
    Grant                     SA_REP
    
    SQL> SELECT last_name,job_id,department_id
      2  FROM employees
      3  WHERE last_name = 'grant';
    
    no rows selected
    View Code

    Using the LIKE Condition

    • Use the LIKE condition to perform wildcard searches of valid search string values.
    • Search conditions can contain either literal character or numbers:
      • % denotes zero or many characrters.
      • _ denotes one character
    • You can combine pattern-matching characters
    SELECT last_name FROM employees WHERE last_name LIKE '_o%';
    •  You can use the ESCAPE identifier to search for the actual % and _ symbols. 
    SELECT employee_id,last_name,job_id
    FROM employees
    WHERE job_id LIKE '%SA\_%' ESCAPE '';

    Using the NULL Conditions

    null value的比较只能使用IS NULL或者IS NOT NULL而不能使用=,<>符号进行比较.  

  • 相关阅读:
    linux下安装mysql
    简单理解:使用linux的ip地址访问Java项目
    上传项目到github完整步骤及如何删除项目
    解决service iptables save出错please try to use systemctl.
    PCI1255信号采集板卡的干扰来源和解决办法
    L298N驱动的再利用
    千里狼-高速采集相机试用记录
    调试研华PCI1245E记录
    超大型的迷宫
    labview实现模拟python微信模块
  • 原文地址:https://www.cnblogs.com/arcer/p/3157062.html
Copyright © 2020-2023  润新知