Step 1:

Sometimes you need to connect two tables together. In this way you would use relational tables and assign primary keys and foreign keys. Then you'd "join" them together in your recordset so that when you ran your query, you'd have info stored for both available.

 

Step 2:

The purpose for all of this is to optimize your tables. Therefore a change made in one location could be updated globally eliminating tedious work.

 

Step 3:

In this example, you have set up a table for venues for orienteering site. Each venue is set up with a venueID.

 

Step 4:

In your events table, add a new field after your eventID. This field will be your foreign key. Give this a name of event_venueID, MEDIUMINT, 8 length.

Do not auto-increment like you do for the primary keys.

 

Step 5:

The naming convention of first_secondID means that first is the prefix of the table name your in. Second is the original table your relating your table to.

 

Step 6:

Now in your table, you can give a number value to each event_venueID. Example, Vasquez Rocks = 1, Griffith Park = 2, Long Beach = 3.

 

Step 7:

Now when you enter new records, you can put the value of the event_venueID and therefore your relating it to the venue location in the above step.

 

Step 8:

You can enter more event records now..as many as you like. As long as you assign a number specified for your event_venueID, it will always know what venue you are linking that record too.

 

---->

Adding new binding fields into your .php page

 

Step 1:

After your join, you will have all the binding from your events and venues tables.

 

Step 2:

You can add a new binding from one of the tables into your .php page.

 

---->

Change your SQL Query.

 

Step 1:

Click on the bindings tab to open the existing query.

 

Step 2:

Click on the advanced button.

 

Step 3:

You can use the dreamweaver buttons to write the following query:

 

SELECT*

FROM events, venues

WHERE events.event_venueID = venues.venueID

 

Step 4:

In the WHERE statement, you are relating the foreign key to the primary key.

 

 

Step 5:

Hit test will show you the results of your query.