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

  • Home
  • SEARCH
  • 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 3214880
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T15:06:45+00:00 2026-05-17T15:06:45+00:00

I have 3 employers IDs: 1, 2 and 3. I am generating tasks for

  • 0

I have 3 employers IDs: 1, 2 and 3. I am generating tasks for each one by adding a line in database and in column “for_emp” I insert IDs I want to assign this task for and could be all 3 of them separated by comma. So let’s say I got a task and “for_emp” is “1,2,3”, the employers IDs. If I would like to select all tasks for the ID 2, will I be able to select from the row that has “1,2,3” as IDs and just match “2” there ? If not, how do you suggest I insert my emp IDs into one row in database ? The db is MySQL.

Any ideas ? Thanks.

  • 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-05-17T15:06:46+00:00Added an answer on May 17, 2026 at 3:06 pm

    Don’t do it like that, you should normalize your database.

    What you want to do is have a table such as task, and then task_assignee. task_assignee would have fields task_id and user_id. If a task has eg. three assignees (IDs 1, 2 and 3), then you’ll create three rows in the task_assignee table for that one task, like this:

    +--------+---------+
    |task_id | user_id |
    +--------+---------+
    |   1    |    1    [
    |   1    |    2    [
    |   1    |    3    [
    +--------+---------+
    

    Then it’s just a simple matter of querying the task_assignee table to find all tasks that are assigned to a given user.

    Here’s an example of how to get all the tasks for user_id 2:

    SELECT t.* FROM task AS t INNER JOIN task_assignee AS ta WHERE ta.user_id = 2
    

    EDIT.

    Just as a related note, even if you didn’t do it the right way (which I described in my answer previously), doing it with hacks such as LIKE would still be far from the optimal solution. If you did store a list of comma-separated values, and needed to check if eg. the value 2 is in the list, you could use the MySQL’s FIND_IN_SET function:

    SELECT * FROM task WHERE FIND_IN_SET(2, for_emp)
    

    But you shouldn’t do this unless you have no choice (eg. you’re working with someone’s shitty DB design), because it’s way more inefficient and won’t let you index the the employee ID.

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

Sidebar

Related Questions

Let's imagine I have a relational database in which, among other things, I want
I have an array of employee ids: 34 , 35, 40, 67, 54 and
For some time I’ve seen employers demanding Sharepoint knowledge from programmers, but I have
Problem statement We have one employer that wants to interview N people, and therefore
I am creating a database that will help keep track of which employees have
I have a database of Employees and a dropdown list which I generated with
I have a table with shifts history along with emp ids. I'm using this
I have a sharepoint 2007 list in which there is a column 'EmpID' which
I want to generate URL like.. It should include two IDs with employer and
I have such table: CREATE TABLE employee ( id INTEGER DEFAULT NEXTVAL('ids'::regclass) NOT NULL,

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.