Description of the role of MYSQL where 1=1 decision _mysql

Source: Internet
Author: User
So on the Internet

Check the check, here is a brief discussion:
1=1 forever True, 1<>1 forever false.

The use of 1<>1:
Used to take only the structure without data
For example:
CREATE TABLE Table_temp tablespace tbs_temp as
SELECT * FROM Table_ori where 1<>1
Build a table table_temp the same as the Table_ori structure, but don't table_ori the data. (except table structure, other knots

Structure as well)

The usefulness of 1=1
for dynamic SQL
For example lv_string: = ' Select Tbl_name,tbl_desc from tbl_test where 1=1 ' | | L_condition;
L_condition: = ' and tbl_name = ' abc ' When the user selects the queried name ' abc ';

L_condition is empty when you select a name query lv_string = ' Select Tbl_name,tbl_desc from Tbl_test

Where 1=1 ', there is no error in the operation, equal to the absence of a restricted name condition. But if there is no 1=1 condition, then lv_string =

' Select Tbl_name,tbl_desc from Tbl_test where ';

In addition to the 1=1 or 1<>1 other than the conditions of perpetual and permanent leave the same.
Related Article

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.