SQL queries the total number of qualified records in the database.

Source: Internet
Author: User

SQL queries the total number of qualified records in the database.

1. select count (*) from table; // count the number of tuples

2. select count (column name) from table; // count the number of values in a column

3. select count (*) from table where field = ""; // The total number of records that meet the condition

4. SQL _count = "select count (*) from article a where 1 = 1 ";

// In this statement, a represents the article table. You can write a. field next to it to represent the field of the table. where 1 = 1, which is equivalent to providing a where. Because 1 = 1 is always true.

You can add and a. Field = "" after the statement based on whether or not to add conditions.

Example:

SQL _count = "select count (*) from article a where 1 = 1"; if (! "". Equals (title) & title! = Null) {SQL _count + = "and a. a_title like '%" + title + "% '";}

The above section describes the total number of qualified records in the SQL query database. I hope it will help you. If you have any questions, please leave a message, the editor will reply to you in a timely manner. Thank you very much for your support for the help House website!

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.