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
WHEREclause, not after the limit clause. How about this?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;