How does SQL query the total number of eligible records in the database
SQL how to query the total number of qualified records in the database, for this problem, this article describes the corresponding analysis and solution in detail, hoping to help more small partners who want to solve this problem find a simpler and easier way.
1. select count(*) from table; //count the number of tuples
2. select count(column name) from table; //count the number of median values in a column
3. select count(*) from table where field = ""; //Total number of records that match this condition
4. sql_count = "select count(*) from article a where 1=1 ";
//In this statement, a represents the table of article, followed by a. field to represent the fields of the table, where 1 = 1, which is equivalent to providing a where. 1=1 is always true.
You can add and a. field = "", etc. after the statement according to whether you need 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+"%'"; } About SQL how to query the total number of qualified records in the database to share the answer here, I hope the above content can be of some help to everyone, if you still have a lot of doubts, you can pay attention to the industry information channel to learn more related knowledge.