Configuring a mysql table or query to meet these needs
Okay so I have gotten the gist of most of mysql query and how to set-up my
table however I am a little lost on how I can do this.
I currently have a table that has this format:
tag_target_id | tag_id | sub_tag_id | tag_target_name | tag_type_id
int(11) | int(11) | int(11) | varchar(255) | int(11
<PK> | <FK> | <FK> | | <FK>
A single tag_target_id corresponds to one piece of content ie. a video,
article etc. now in the table there should be multiple entries with the
same tag_target_id and tag_target_name and different tag_id , sub_tag_id ,
tag_type_id simple enough
So my problem is when I am inserting data into the table I have a PDO
query that looked like this:
"INSERT INTO phpro_tag_targets (tag_id, sub_tag_id, tag_target_name,
tag_type_id)
VALUES (:tag_id, :sub_tag_id,:tag_target_name,:tag_type_id)"
... I used to have tag_target_id as auto increment however each new query
obviously incremented the tag_target_id so a single piece of content would
have tag-target_id = 5, 6, 7, 8, 9 for eg. where I would like to have each
piece of new content have one single tag_target_id
Now I would like to somehow have each new piece of content have a new
tag_target_id but not each entry into the table for a single piece of
content have it's own unique idea
so for eg. for one piece of content in the table all data for that content
could look like this:
tag_target_id | tag_id | sub_tag_id | tag_target_name | tag_type_id
int(11) | int(11) | int(11) | varchar(255) | int(11
54 | 22 | 64 | url_to_content | 16
54 | 66 | 82 | url_to_content | 24
54 | 22 | 77 | url_to_content | 18
54 | 87 | 55 | url_to_content | 16
54 | 66 | 92 | url_to_content | 20
So how can I change the structure of the table or write a query set to
achieve this desired output? Thanks in advance for any advise or help with
this!
No comments:
Post a Comment