Multiple categories with one posts in sql query in php/mysql -


i made 2 tables

  1. posts
  2. categories

in posts table created category column, here store multiple category_id 1,2,3.

the problem if category column has single category_id 1 or 2 or 3, can query data this:

select title posts category = $category_id 

however, unsure how query comma-delimited data. there way this, or should change table structure ?

you either create junction table (probably eav design) or keep unique table , use find_in_set, such :

select title posts find_in_set(1, category) > 0 

Comments

Popular posts from this blog

aws api gateway - SerializationException in posting new Records via Dynamodb Proxy Service in API -

asp.net - Problems sending emails from forum -