Home > database >  Where after the use case when problems
Where after the use case when problems

Time:09-25

Select * from the User where 1=1
And (in the case when the User. The department='sales' then Table. The User ID=' 001 '
The else Table. Users ID<> NULL end);

The SQL requirement is,
Sales department only can view their account information, if the department as' sales department, specifies the incoming user ID (such as' 001 '] for conditions;
Other departments can view all the user information, the 'sales department is to see all the query results,

If I write directly and Table. The user ID='001' is no problem, but in the case when will prompt '=' near a syntax error, is this why? Is my grammar have what problem?

Because of the new, also just know this website soon, just apply for account, integral is not much, sincerely ask, thanked here!

CodePudding user response:

The building Lord your fields can be in Chinese

CodePudding user response:

Behind the where can use case, but also get A=B is equation

CodePudding user response:

Is not a field is in Chinese, is the original sentence is too long, I wrote a brief, long also use Chinese simplified the field name

CodePudding user response:

refer to the second floor to learning turn _ response:
behind the where can use case, however, also have A=B is equation


Uh... What's that mean? Can say clearly some?

CodePudding user response:

When you login in the user login ID or login ID to department?

CodePudding user response:

refer to fifth floor daily necessities sauce vinegar 0 reply:
when you login in the user login ID or login ID to department?


Users, only that will determine whether the query information, if the user is the sales department, with its own user ID as a query conditions

CodePudding user response:

After then, can only be returned, you can't judge or assignment is, that is to say, then, can't use=number,

CodePudding user response:

refer to 7th floor AHUA1001 response:
then, only the content of the return, you can't judge or assignment is, that is to say, then, can't use=,


embarrassing, that what judgment method recommended?

CodePudding user response:

Is the case when then the else end as the query of a value, and then judge expression with your values