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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T07:08:19+00:00 2026-06-18T07:08:19+00:00

i have a mysql table category with a field events as varchar which its

  • 0

i have a mysql table category with a field events as varchar which its values is like this : 11,29,32.and this values referer to event table ID. ( so i can say : i have a several event ID from event table in category table)

So i want to select events from category like that :

 SELECT *
FROM                      
event e, category c                                                    
where e.event_id in (c.events)

But that not give the correct result instead when i put the values manually like :

   SELECT *
FROM                      
event e, category c                                                    
where e.event_id in (11,29,32)

I hope that’s clear,

Any help please

  • 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-18T07:08:20+00:00Added an answer on June 18, 2026 at 7:08 am

    Part of your problem is the way that you have set up your tables. Typically you will have an events, category and then a join table between the two. You should not store data in a comma separated list to query against.

    If you cannot alter your table structure, then you can use the MySQL function FIND_IN_SET():

    SELECT *
    FROM event e
    INNER JOIN category c                                                    
      on find_in_set(e.event_id, c.events)
    

    See SQL Fiddle with Demo

    If you can alter your tables, then the structure should be:

    create table events
    (
      event_id int not null auto_increment primary key,
      event_name varchar(50) not null
    );
    
    create table category
    (
      cat_id int not null auto_increment primary key,
      cat_name varchar(50) not null
    );
    
    create table events_category
    (
       event_id int not null,
       category_id int not null,
       PRIMARY KEY(event_id, category_id),
       constraint fk_event 
        foreign key (event_id) references events (event_id),
       constraint fk_category 
        foreign key (category_id) references category (cat_id)
    );
    

    Then when you query the data you would use:

    select *
    from events e
    left join events_category ec
      on e.event_id = ec.event_id
    left join category c
      on ec.category_id = c.cat_id
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a MySQL table like id | text | category | active I
I have a MySQL table that looks something like this: +-----+------------+ | id |
I have a MySQL table and one of the fields is category, the values
I have MySQL InnoDB table utf-8 encoded. This table has only id and name
I have a MySQL table and would like to return the rows based on
I am using Heidi and I have this Table: Table Category: id title parent_id
I have a mysql table id,name,gender,age religion( enum('HIN','CHR','MUS') ,category(enum('IND','AMR','SPA') where last 2 are enum
I have a table which has no primary key and I can't add one
I have a php code which generates a list from a field in mysql
I have 3 tables: table events . In this I have fields such as

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.