mysql查詢字段不為空的記錄

查詢不為空的所有記錄
SELECT id,firstname,lastname,mail FROM testdb.users WHERE mail!='';
或者
SELECT id,firstname,lastname,mail FROM testdb.users WHERE LENGTH(mail)>0;

mysql查詢一個表的記錄的總數
SELECT count(*) FROM table_name;
或者
SELECT count(*) as num FROM table_name;

本文來自於 lynnteng0 的BLOG

You May Also Like