0

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?

6 Answers 6

3

What's wrong with:

SELECT * FROM `table` WHERE `id` <> 5
Sign up to request clarification or add additional context in comments.

1 Comment

Sorry for the simple question guys, this is just what I needed! I'm new-ish to MySQLi and its terms. :) Edit :: will accept in 7 mins when I can as you were the first with the answer I needed.
1
SELECT * FROM `users` WHERE `userID` != 5

Replacing 5 with the current user's ID should do the trick.

Comments

1

Why not just

 SELECT * FROM table WHERE userid != 'currentUser'

Comments

1

$query = "SELECT * FROM users WHERE userId != $userId" ;

$userId can contain the user defined id

Comments

0
SELECT * FROM table WHERE NOT user_id = < id >

Comments

0
SELECT *

FROM (SELECT ROW_NUMBER() 

OVER(ORDER BY id) RowNr, id FROM tbl) t

WHERE RowNr BETWEEN 10 AND 20

1 Comment

This does not answer the question but actually leads onto a false trail. No row numbers or analytic functions required.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.