Reputation: 152
me again!
So I'm wondering what the sequel/php code is to display all the rows in a table except one row. So display row 1, 2, 3 and 4 and every column, but don't display anything to do with row 5. The reason for this is I want to display all users in a user table except the user that is looking at the list itself.
Checking which user is looking at the list is fine because I can use a variable I set aside called userid which can be used to check it against. I just don't know the SQL terminology I need to use to essentially "select * from table except this row".
Any help please?
Upvotes: 0
Views: 3142
Reputation: 16
SELECT *
FROM (SELECT ROW_NUMBER()
OVER(ORDER BY id) RowNr, id FROM tbl) t
WHERE RowNr BETWEEN 10 AND 20
Upvotes: 0
Reputation: 119
$query = "SELECT * FROM users WHERE userId != $userId" ;
$userId can contain the user defined id
Upvotes: 1
Reputation: 29250
SELECT * FROM `users` WHERE `userID` != 5
Replacing 5 with the current user's ID should do the trick.
Upvotes: 1