SQL operator Operations

Source: Internet
Author: User

Arithmetic operators:

Use Select to achieve subtraction, mold operation, etc.:

SELECT 6+4addition operation,6-4subtraction operation,6*4multiplication operation,6/2division operation,6Div2division operation,6%4die-finding operation,6MOD4Die-finding operation;

In addition to this, you can directly manipulate the properties in the table:

SELECT ename employee, Sal monthly salary, Sal*  Annual salary   from T_employee;

Comparison operators:

Returns 1 if the condition is met, otherwise returns 0;

SELECT 1=1numerical comparisons,'Cjgong'='Cjgong'string comparisons,1+2=3+3expression comparison,1<=>1numerical comparisons,'Cjgong'<=>'Cjgong'string comparisons,1+2<=>3+3Expression comparison;

In addition, you can use it in the WHERE statement:

Logical operators: You can combine the conditions with a logical operation in where.

True and null vs. or null

SELECT 3  and 4,    0  and 4,    0  and NULL,    3  and NULL,    3 && 4,    0 && 4,    0 && NULL,    3 && NULL;

SELECT   from where col1=and=or col3>

Bitwise operators:

The bin function can view the binary:

SELECT 5 & 6 , BIN (5&6) binary number,  4&5&  6, BIN (4&5&6) binary number;

SELECT 3Xor4,    0Xor0,    NULLXorNULL,    0Xor4,    0XorNULL,    3XorNULL;

NULL and any data XOR return null

SQL operator Operations

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.