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 7794727
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T22:51:33+00:00 2026-06-01T22:51:33+00:00

I have 2 sql tables Table name: agents contains a records with a coloumn

  • 0

I have 2 sql tables
Table name: agents contains a records with a coloumn AgentID

Table named: vacancies is the one with the data ans is being dislayed.
Table named vacancies has vacancies.Agents which contains values simmilar to this

VacanyID    Company       position        CTC        Candidates        Agents
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
FBVAC001  | HDFC      |  Branch Manager | 4.5  | FBCAN001,FBCAN002| Agent3,Agent4
FBVAC003  | TBNH      |  Branch Manager | 4.5  | FBCAN004,FBCAN005| Agent2,Agent4
FBVAC005  | MMNT      |  Branch Manager | 4.5  | FBCAN008,FBCAN006| Agent3
FBVAC008  | LCFC      |  Branch Manager | 4.5  | FBCAN009,FBCAN023| Agent3,Agent4
FBVAC008  | KOTC      |  Branch Manager | 4.5  | FBCAN009,FBCAN023| Agent5,Agent4

I want to run a query that will return only those records that contain the value that corresponds to agents.AgentID from table name agents. This is the query so far but all it returs are those records that do not have more than one value in vacancies.Agents

for example if the value being searched for is Agent3 it should return rows1,3 and 4 instead it only returns row 3.

SELECT
vacancies.VacancyID,
vacancies.Company,
vacancies.`Position`,
vacancies.CTC,
vacancies.Candidates,
vacancies.Agents
FROM vacancies
, agents
WHERE (FIND_IN_SET(vacancies.Agents,agents.AgentID) <> 0)

How can this be resolved?

  • 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-01T22:51:35+00:00Added an answer on June 1, 2026 at 10:51 pm

    I believe you have your parameters backwards in FIND_IN_SET. The set should come second

    FIND_IN_SET(agents.AgentID, vacancies.Agents)
    

    More Info: http://www.bitbybit.dk/carsten/blog/?p=162


    Also, if you are wanting to see only a specific agent, you need to filter for that as well, otherwise you’re getting every possible combination of agent and matching vacancies (hence the duplicate rows):

    AND Agents.AgentID = 'Agent3'
    

    Demo: http://www.sqlfiddle.com/#!2/b4dcb/3

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

Sidebar

Related Questions

I have 2 Identical tables in SQL Server 2008, one is the Live table
In SQL Server 2008 I have two tables. One table for users: id_user -
I have two tables: EmployeeTypeA table Name varchar(2000) field contains - 'john,sam,doug' EmployeeTypeB table
I have the following 3 classes(mapped to sql tables). Places table: Name(key) Address Capacity
I have 2 tables in SQL: Table 1 Step Id Step Name Table 2
I have a SQL table with only two columns: nameid and name. I want
I have a Database (SQL Server) with table named 'ProcessData' and columns named 'Process_Name'
I have the following tables in SQL Server 2005 ReceiptPoint: ID (PK), Name GasIndexLocation:
I have a table called 'Audit' in SQL Server 2005 like this: Name |
I have a query as follows: String SQL = insert into table (id, name)

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.