Oracle Conditional Query Fuzzy query

Source: Internet
Author: User

Example:

1) Find employee information with a salary above 3000

SELECT *

Froms_emp E

where e.salary>3000;

2) Find all information about employees who are known as Carmen

SELECT * FROM S_emp E

Wheree.first_name = ' Carmen ';

"Oracle SQL keywords, table names, column names, etc. are case insensitive, and the values in the records are case sensitive"

3) Find out the employee information without performance

SELECT * FROM S_emp E

Where e.commission_pct is not null;

4) Find out the employee's name, department number and salary at 1200-3000.

Selecte.first_name,e.dept_id,e.salary

Froms_emp E

Wheree.salary>=1200 and e.salary<=3000;

Selecte.first_name, E.dept_id,e.salary

Froms_emp E

Wheree.salary between and 3000;

    • Like : Fuzzy Query

Wildcard characters% and _

% : Represents any number of characters

_ : represents any one character

1) Find information about employees whose names contain letters ' a '

SELECT * FROM S_emp E

where e.first_name like '%a% '

2) Check out the name of the employee whose first letter is ' S ' in the employee's name

SELECT * FROM S_emp E

Wheree.first_namelike ' s% '

3) Find information about employees whose names contain ' a ' and ' F '

SELECT * FROM S_emp E

Wheree.first_name like '%a% ' and e.first_name like '%f% ';

4) Check out the employee's name with the third-last letter ' I ' information

SELECT * FROM S_emp E

Wheree.first_name like '%i__ '

5) Check out the names, department numbers and positions of all employees in 31, 41 departments

Selecte.first_name,e.dept_id,e.title from S_emp E

wheree.dept_id = or e.dept_id = 41;

Selecte.first_name,e.dept_id,e.title from S_emp E

where e.dept_id in (31,41);

"In (31,41) equivalent: dept_id=31 or dept_id=41"

6) Find employees who are neither sales nor clerks

SELECT * FROM S_emp

where title! = ' Sales representative ' and title! = ' Stock clerk ';

SELECT * FROM S_emp

Where title isn't in (' Sales representative ', ' Stock clerk ');

"Not in (' Sales representative ', ' Stock clerk ') equals"

Title! = ' Sales representative ' and title! = ' Stock clerk '

    • "Dual table: Virtual tables in Oracle to ensure complete SQL statements. "

"Get the value of 4+30"

Select (4+30) from dual;

"Get Current system Time"

Select sysdate from dual;

"Get ' hello '"

Select ' Hello ' from dual;

Oracle Conditional Query Fuzzy query

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.