MySQL: Syntax: virtual table dual

Source: Internet
Author: User

There are dual virtual tables similar to those in Oracle in MySQL: the official statement is purely to satisfy the habit of select... from,MySQL ignores the reference to this table.

You can pay attention to the following:

    1. Select * from dual; MySQL will have an error-- 1096: The table is not used. Oracle returns the column "du" with the value "X". The behavior is the same as that of a regular table with only one row of records!
    2. Select express [from dual]; MySQL is always executed as a normal SELECT statement that returns the value of this expression, and returns the result set of a row of records. From dual is simply a decoration for MySQL!In Oracle, this sentence must contain from dual; otherwise, an error is returned!
    3. Select express from dual where 0 = 2; The behavior of mysq is the same as that of Oracle: This statement is just like the normal table you think -- The where condition is calculated first and then the express statement is calculated. The where condition here determines whether expres will return!

To sum up:

    • Oracle dual hasCodeAesthetic, unified style, conventions become vulgar!
    • In SQL Server, select has the characteristics of combining MySQL with Oracle:
  1. select * sqlserver reports an error similar to MySQL -- you must specify a table. This is completely a sentence, and no one will recognize it!
  2. select express sqlserver is similar to MySQL. A valid statement returns the result set of a row of records.
  3. select express where 0 = 2 sqlserver features: The from clause is not required. Consider the WHERE clause to determine whether to return the result set
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.