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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T18:43:37+00:00 2026-05-12T18:43:37+00:00

I currently have the following row in my table: course_data: user_id days <– This

  • 0

I currently have the following row in my table:

         course_data:
             user_id        days     <-- This is a varchar column.
               405          1,3,5

and I am trying to implement the following SELECT statement:

SELECT usrID, usrFirst, usrLast, usrEmail
    FROM tblUsers
    WHERE usrID NOT IN
    (
        SELECT users.usrID
            FROM
                `course_data` courses,
                `tblUsers` users
            WHERE
                days IN ('$day')
    )
    GROUP BY usrID
    ORDER BY usrID

Basically, I want that row (with user 405) to be omitted if the $day variable includes a ‘1, 3, or 5’.

For example, if $day = "1", it should return an empty query (because the number “1” is in the column “1,3,5”).

However, I have not found this to be the case. Even though $day = "1", it still returns that row.

The only way that it won’t return the row is if $day= "1,3,5." Yet, I thought that the IN() clause would take any part of my variable and apply it to that column.

Any insights on what I’m doing wrong here? 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-12T18:43:37+00:00Added an answer on May 12, 2026 at 6:43 pm

    You should use the like keyword to do a partial match of the char field:

    where days like '%1%'
    

    Edit: VolkerK and Lukas Lalinsky both suggest MySQL’s find_in_set, which is probably better than like for what you want to do. However, the following recommendation about normalizing your database still applies.

    However, you should not store multiple values in a single database field. Instead, consider using two tables:

    course_data:
        user_id
    
    course_days:
        user_id
        day_number
    

    Then, you would have the following data:

    course_data:
        user_id
        405
    
    course_days
        user_id    day_number
        405        1
        405        3
        405        5
    

    You can then correctly query this schema. For example:

    select  cd.user_id
    from    course_data as cd
    where   cd.user_id not in
        (
            select  course_days.user_id
            from    course_days
            where   course_days.user_id = cd.user_id
                and course_days.day_number = 1
        )
    

    (or, that should be close; I’m not exactly sure what you’re trying to accomplish or what the rest of your schema looks like, so this is a best guess).

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

Sidebar

Related Questions

I currently have a table with a column as varchar . This column can
I have an InnoDB table with a lock timeout column. If this column is
I currently have a html table (with 2 columns) and I am trying to
I currently have the following CSS for my 4 columns which might grow to
I currently have the following objects persisting successfully: Person first name, etc. Exams title,
I currently have the following MySQL statement to replace the HTML entity for a
I currently have the following js code function clearMulti(option) { var i; var select
currently I have the following code: String select = qry.substring(select .length(),qry2.indexOf( from )); String[]
I currently have code that does the following: private final static ExecutorService pool =
I currently have a class file with the following enumeration: using System; namespace Helper

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.