Click here to Skip to main content
15,891,136 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more: (untagged)
Hi all,

Is there any way to query statement to select all data but without specific data to add into the statement example below?

Example:- SELECT * from databasename.tblUser;

I have tblUser. The database hold all the user ID. But I want the statement to select all data from table without the current user login ID. Is it possible?
Posted

Put the condition in the where clause:
SELECT * from databasename.tblUser WHERE userid <> 'value of current user login id'
 
Share this answer
 
Comments
Luiey Ichigo 13-Mar-14 22:12pm    
it not view other data..all not shown at database.. i test this query on mysql workbench..i try your way and this SELECT * from malldir.tblUser WHERE userid <> 'admin'; but nothing show in result. any other way?
Luiey Ichigo 13-Mar-14 22:13pm    
I try this and work..SELECT * from malldir.tblUser WHERE userid !='user';

tq for giving the idea.
TRY THIS....:)

SQL
SELECT * from tblUser WHERE userid not in (@UserID)
 
Share this answer
 
Comments
Luiey Ichigo 13-Mar-14 22:11pm    
it not view other data..all not shown at database.. i test this query on mysql workbench..i try your way and this SELECT * from malldir.tblUser WHERE userid not in (@'admin'); but nothing show in result. any other way?
Luiey Ichigo 13-Mar-14 22:13pm    
I try this and work..SELECT * from malldir.tblUser WHERE userid !='user';

tq for giving the idea.
Nirav Prabtani 14-Mar-14 0:35am    
my query is only for mssql not for mysql
Luiey Ichigo 17-Mar-14 3:15am    
Oh..so the is some differ from database?is it sql statement is same to all database regardless it is oracle,mysql,mssql etc?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900