I have to insert a database in the database assigned to more than one category, how could I do this? In case it would appear the category options available in my bank and I would select them with a checkbox
I have to insert a database in the database assigned to more than one category, how could I do this? In case it would appear the category options available in my bank and I would select them with a checkbox
In this case your tables in the database should have more or less these structures:
|--------artigo----------|
|id - titulo - nome - etc|
|------------------------|
|---categoria---|
|id - nome - etc|
|---------------|
|-------artigo_categoria------|
|id - id_artigo - id_categoria|
|-----------------------------|
This gives you an article that has more than one category.
When doing select
just use a inner join
to associate.
select * from artigo
inner join artigo_categoria on (artigo.id = artigo_categoria.id_artigo)
inner join categoria on (artigo_categoria.id_categoria = categoria.id)