I need to Select the employees from Department10 where the name does not contain the string "LA".
Select *
From EMP
Where Cod_Dept = 10
I need to Select the employees from Department10 where the name does not contain the string "LA".
Select *
From EMP
Where Cod_Dept = 10
Select *
From EMP
Where Cod_Dept = 10
And Name Not Like '%LA%'
Here is another option using CHARINDEX()
:
SELECT *
FROM EMP
WHERE Cod_Dept = 10
AND CHARINDEX('LA' , Name , 0) = 0;
In case you have Null
value and you want to return it too:
SELECT *
FROM EMP
WHERE Cod_Dept = 10
AND (CHARINDEX('LA' , Name , 0) = 0) OR (CHARINDEX('LA' , Name , 0) Is Null);
Demo.