Description of the functions of MYSQL where 1 = 1 Determination

Source: Internet
Author: User

So on the Internet

After checking, let's talk about it here:
1 = 1 permanent, 1 <> 1 permanent false.

1 <> 1 usage:
Used to retrieve only structures without data
For example:
Create table table_temp tablespace tbs_temp
Select * from table_ori where 1 <> 1
Create a table table_temp with the same table_ori structure, but do not use data in table_ori. (Except for the table structure

Likewise)

1 = 1
For dynamic SQL
For example, lv_string: = 'select tbl_name, tbl_desc from tbl_test where 1 = 1' | l_condition;
When the user selects the query name 'abc', l_condition: = 'and tbl_name = "abc" "; but when the user does not

During name query, l_condition is null. lv_string = 'select tbl_name, tbl_desc from tbl_test

Where 1 = 1', the operation will not go wrong, which is equivalent to no restriction on name conditions. However, if there is no 1 = 1 condition, then lv_string =

'Select tbl_name, tbl_desc from tbl_test where'; then an error is returned.

Other conditions except 1 = 1 or 1 <> 1 are 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.