1

I want to show all data from "employee" table except the details of user which is logged in?

eg:

EMP_ID | EMP_Name

  1    |  Mike
  2    |  Peter
  3    |  Drake
  4    |  Oliver
  5    |  Andrew

Suppose, my current login user is "Peter" whose EMP_ID is 2, so I want to show table like this...

EMP_ID | EMP_Name

  1    |  Mike
  3    |  Drake
  4    |  Oliver
  5    |  Andrew

Basically I want to hide the details from table of current user. Please help me how to achieve it??

2
  • select only values that u want to show not "SELECT * FROM" Commented Mar 8, 2017 at 18:21
  • 1
    get the id of current logged in user and then SELECT WHERE id != currentId where currentId is id of current logged in user Commented Mar 8, 2017 at 18:25

2 Answers 2

3

Essentially you have to select everything you want and eliminate what you don't want:

SELECT *
FROM `employees`
WHERE `EMP_ID` != 2; -- eliminates Peter
Sign up to request clarification or add additional context in comments.

Comments

2
 $query = "select EMP_ID, EMP_Name from EMPLOYEES where EMP_ID <> $emp_log";

I think that you know who is log by using a session var, so the var $emp_log must be get from the session var, ex.

 $emp_log = $_SESSION['emp'];

Comments

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.