Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7746473
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T10:17:12+00:00 2026-06-01T10:17:12+00:00

how to write query for following request? my table: id designation 1 developer,tester,projectlead 1

  • 0

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
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T10:17:14+00:00Added an answer on June 1, 2026 at 10:17 am

    You need to use the boolean operators AND and OR in conjunction with LIKE:

    IF empid = 1 AND (empname LIKE '%venkat%' OR empname LIKE '%vasu%')
    

    The above example will return all rows with empid equals 1 and empname containing venkat or vasu.

    Apparently you need to create that query based on the input from user, this is just an example of how the finally query should look like.

    Edit: Trying to do this within SqlServer can be quite hard so you should really change your approach on how you call the stored procedure. If you can’t do this then you could try and split your designation parameter on , (the answers to this question show several ways of how to do this) and insert the values into a temporary table. Then you can JOIN on this temporary table with LIKE as described in this article.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need to write the following query so the att field is always a
I'm trying to write a Linq2XML query to query the following XML. I need
I am struggling to write a query to result in the following records. I
I need to write a WordPress query to accomplish the following - I am
Is it possible to write single query for following scenario? Scenario - Table -
I wanted to write following query through codeigniter's db helper class, guide me plz
I write the following query: select id, (select NameEn from [Campaign] where id=CampaignId) as
I cannot figure out how to write the following query using the DbFinderPlugin 1.2.2
I want to write a SQL query like the following. Its syntax is not
how do i write the following sql query in Lambda expression. select rating from

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.