zoukankan      html  css  js  c++  java
  • 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而不能使用=,<>符号进行比较.  

  • 相关阅读:
    [CF1039D]You Are Given a Tree
    [洛谷P2107]小Z的AK计划
    [CF409F]000001
    [洛谷P1801]黑匣子_NOI导刊2010提高(06)
    [洛谷P3377]【模板】左偏树(可并堆)
    [洛谷P2482][SDOI2010]猪国杀
    [CF45G]Prime Problem
    [CF735D]Taxes
    [洛谷P3413]SAC#1
    [洛谷P4124][CQOI2016]手机号码
  • 原文地址:https://www.cnblogs.com/arcer/p/3157062.html
Copyright © 2011-2022 走看看