0

I have two tables that I would like to work together (stories and events). Stories is a table that is used to produce articles on a website and events is a series of events put into a table. I would like to be able to add events to story based on the data in the story table.

Each story in stories has a unique Story_Code and also has fields like events1, events2, events3, events4 etc.

Each event in events has a unique Event_Code.

I would like to be able to have the user when posting a story in the stories table to be able to enter the Event_Code and that would pull in the data from the events table, but I am at a loss as to how to do it.

Currently, I can pull them based on the date as follows:

("SELECT * FROM events where Date = '2014-11-22' order by Icon ASC, Date DESC, Timestamp DESC")

What I want to do is change the where clause to fetch the event_codes specified by the user in the story table by story_code.

I think I need to define a variable for events1, events2 etc and then once it is defined, I can use that in my where clause.

Any help would be appreciated...

2
Contributors
2
Replies
11
Views
2 Years
Discussion Span
Last Post by ceeandcee
1

I don't think you have the right structure. I would create a link table:

story (as you have it but without events1, events2... fields)
events (as you have it)
story_events (se_id, story_id, event_id)
This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.