For the query below, some results have nothing in the database for "age." How can I exclude these values that have nothing for "age"?
$sqlStr3 = "SELECT
username
,loginid
,age
FROM login
ORDER BY age ASC
LIMIT $offset, $rowsperpage";
If age defaults to NULL (the typical case), add a simple WHERE age NOT NULL
check:
SELECT
username
,loginid
,age
FROM login
WHERE age NOT NULL
ORDER BY age ASC
LIMIT $offset, $rowsperpage
You could use a Where clause but it's easier and faster to just add the IS NOT NULL
operator to your SELECT for that field.
$sqlStr3 = "SELECT
username
,loginid
,age IS NOT NULL
FROM login
ORDER BY age ASC
LIMIT $offset, $rowsperpage";
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.