What does 1 in the Select 1 from table statement mean?

Source: Internet
Author: User

Here I mainly discuss the following SELECT statements:

The Doo_archive table is a data table with rows of 4 rows, as follows:


use three SELECT statements, select 1 from doo_archive,Select COUNT (1) from doo_archive,Select The sum (1) from doo_archive is tested and the results are as follows:

1: Test results, draw a line number and doo_archive A temporary column with the same number of table rows, the column value for each row is 1, as follows:


2: Draw a number, the number is doo_archive the number of rows in the table is 4, as follows:


3: Draw a number, the number is doo_archive the number of rows in the table is 4, as follows:



Then I used select 2 from doo_archive, select COUNT (2) from doo_archive, select SUM (2) from the doo_archive test, The results are as follows:

1: Get a temporary column of the same number of rows and doo_archive table rows, the column value of each row is 2;


2: A number is obtained, which is the number of rows in the doo_archive table;


3: A number is obtained, which is the number of rows X2 of the doo_archive table.



Then I use select from doo_archive, select COUNT (Ten) from Doo_archive, select SUM (Ten) from Doo_archive Test:

1: Draw a temporary column (10) with the same number of rows as the doo_archive table row, and the column value for each row (10) is the number I write after the select;


2: A number is still obtained, which is the number of rows in the doo_archive table (4);


3: Draw a number that is the number of rows (4) x of the doo_archive table (10), or 40, that is written in the select.


In summary: I found that the first way to write is to increase the temporary column, the column value of each row is written in the number of select, the second is that regardless of how a value of count (a) changes, the resulting value is always the number of rows of table tables;

What does 1 in the Select 1 from table statement mean?

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.