The experiment tells you the misleading usage of or and between in the where condition (refuse to repost, which is mandatory for violators)

Source: Internet
Author: User

SQL> select * from EMP;

Empno ename job Mgr hiredate Sal comm deptno
------------------------------------------------------------------------------
7369 Smith clerk 7902 17-dec-80 800 20
7499 Allen salesman 7698 20-feb-81 1600 300 30
7521 ward salesman 7698 22-feb-81 1250 500 30
7566 Jones manager 7839 02-apr-81 2975 20
7654 Martin salesman 7698 28-sep-81 1250 1400 30
7698 Blake manager 7839 01-may-81 2850 30
7782 Clark manager 7839 09-jun-81 2450 10
7788 Scott analyst 7566 19-apr-87 3000 20
7839 King President 17-nov-81 5000 10
7844 Turner salesman 7698 08-sep-81 1500 0 30
7876 Adams clerk 7788 23-may-87 1100 20

Empno ename job Mgr hiredate Sal comm deptno
------------------------------------------------------------------------------
7900 James Clerk 7698 03-dec-81 950 30
7902 Ford analyst 7566 03-dec-81 3000 20
7934 Miller clerk 7782 23-Jan-82 1300 10

14 rows selected.

SQL> select * from EMP where ename between 'a 'and 'C ';

Empno ename job Mgr hiredate Sal comm deptno
------------------------------------------------------------------------------
7499 Allen salesman 7698 20-feb-81 1600 300 30
7698 Blake manager 7839 01-may-81 2850 30
7876 Adams clerk 7788 23-may-87 1100 20

SQL> select * from EMP where ename like 'a % 'or ename like' B % 'or ename like 'C % ';

Empno ename job Mgr hiredate Sal comm deptno
------------------------------------------------------------------------------
7499 Allen salesman 7698 20-feb-81 1600 300 30
7698 Blake manager 7839 01-may-81 2850 30
7782 Clark manager 7839 09-jun-81 2450 10

7876 Adams clerk 7788 23-may-87 1100 20

For reprint, please indicate the source and original article links:

Http://blog.csdn.net/xiangsir/article/details/8579489

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.