I have something like this $SQL = "SELECT * FROM profile_comments WHERE name = '$username' LIMIT $offset, $rowsperpage";
but I want to know if it's possible to limit the result just for the null rows of a certain column?
Exemple
$SQL = "SELECT * FROM profile_comments WHERE name = '$username' LIMIT table is NULL 5, 10";
profile_comments
id | parent_id | name | text | datetime
-------------------------------------------------
1 | null | Netra | Bla bla | 00.00.0000
2 | 1 | Netra | Bla bla | 00.00.0000
3 | 1 | Netra | Bla bla | 00.00.0000
4 | null | Netra | Bla bla | 00.00.0000
5 | 4 | Netra | Bla bla | 00.00.0000
You need to pud that condition in the WHERE
clause, not after the limit clause. How about this?
$SQL = "SELECT *
FROM profile_comments
WHERE name = '$username' AND
`table` is NULL
LIMIT 5, 10";
The answer:
SELECT * FROM profile_comments WHERE PARENT_ID IS NOT NULL UNION SELECT * FROM profile_comments WHERE PARENT_ID IS NULL GROUP BY PARENT_ID;
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.