1. select count(*) from table; //統(tǒng)計(jì)元組個(gè)數(shù)
2. select count(列名) from table; //統(tǒng)計(jì)一列中值的個(gè)數(shù)
3. select count(*) from table where 字段 = ""; //符合該條件的記錄總數(shù)
4. sql_count = "select count(*) from article a where 1=1 ";
//這條語句中a就代表article 這張表,后面可以寫a.字段來代表該表的字段,where 1 = 1,就相當(dāng)于提供了一個(gè)where。因?yàn)?=1永遠(yuǎn)成立。
就可以根據(jù)是否需要加條件,在該語句后面加and a.字段 = "", 等等。
例:
sql_count = "select count(*) from article a where 1=1 ";if(!"".equals(title) && title!=null){sql_count +="and a.a_title like '%"+title+"%'"; }以上所述是小編給大家介紹的SQL查詢數(shù)據(jù)庫中符合條件的記錄的總數(shù),希望對大家有所幫助,如果大家有任何疑問請給我留言,小編會(huì)及時(shí)回復(fù)大家的。在此也非常感謝大家對武林網(wǎng)網(wǎng)站的支持!
新聞熱點(diǎn)
疑難解答
圖片精選