how to write query for following request? my table:
id designation
1 developer,tester,projectlead
1 developer
1 techlead
if id=1,designation="'developer'"
Then need to first,second records.Because 2 rows are having venkat.
if id=1,designation="'developer','techlead'"
then need to get 3 records as result.
i wrote one service for inserting records to that table .so that i am maintaining one table to store all designation with same column with comas.
By using service if user pass id=1 designation="'developer','techlead'" then need to pull the above 3 records.so that i am maintaining only one table to save all designations
SP:
ALTER PROCEDURE [dbo].[usp_GetDevices]
@id INT,
@designation NVARCHAR (MAX)
AS
BEGIN
declare @idsplat varchar(MAX)
set @idsplat = @UserIds
create table #u1 (id1 varchar(MAX))
set @idsplat = 'insert #u1 select ' + replace(@idsplat, ',', ' union select ')
exec(@idsplat)
Select
id FROM dbo.DevicesList WHERE id=@id AND designation IN (select id1 from #u1)
END