SQL [Hard query - make or avoid]

SELECT Name, ( NOT (ID_ListGroupParIzm IN (SELECT ID_Param FROM TbUserParam WHERE ID_User=:ID_User ) ) ) Visi FROM CfgListParIzm WHERE ID_ListGroupParIzm=:ID_ListGroupParIzm 

Errors:

 Message 156, Level 15, State 1, Line 1 Incorrect syntax near the keyword "NOT". Message 102, Level 15, State 1, Line 2 Incorrect syntax near the construction ":". 

added: I will try to explain what I want with him.

I need a name from one table and a BOOL value for each Node, which will be false if ID_ListGroupParIzm IN (SELECT ID_Param FROM TbUserParam WHERE ID_User =: ID_User

And ID_ListGroupParIzm (from CfgListParIzm) = ID_Param (from TbUserParam) forget to say: (

btw: it looks like select cannot return a logic value. How to get my target :(

attempt added:

 SELECT Name, COALESCE( ( SELECT TOP 1 0 FROM TbUserParam WHERE TbUserParam.ID_User = :ID_User AND TbUserParam.ID_Param = CfgListParIzm.ID_ListParIzm ), 1) Visi FROM CfgListParIzm WHERE CfgListParIzm.ID_ListGroupParIzm = :ID_ListGroupParIzm 

error: Message 102, level 15, state 1, line 6 Invalid syntax near construction ":".

But ... be sure> _ <I need to redo it as a procedure, thanks.

+4
source share
1 answer
 SELECT Name, COALESCE( ( SELECT TOP 1 0 FROM TbUserParam WHERE ID_User = :ID_User AND ID_ListGroupParIzm = :ID_ListGroupParIzm ), 1) Visi FROM CfgListParIzm WHERE ID_ListGroupParIzm = :ID_ListGroupParIzm 
+3
source

Source: https://habr.com/ru/post/1298997/


All Articles