-
linking mysql tables
I recently started using mysql, and I'm trying out some stuff to learn a bit more. I decided to implement a small music charts system: it will hold the data telling you which song is on which position in a certain week. For now, I use two tables:
[outlaw41]
week
position1
position2
position3
(..all the way to...)
position40
position41
[song]
index
title
artist
album
The second table (song) holds information on the songs themselves. Index is a unique integer.
The first table (outlaw41) holds the information on the charts. Each week, a new row is added, reflecting the charts of that week (which song was on number one, which one was number 2, etc).
My question is: how do I link these tables? Somehow, I want to tell the [outlaw41] table that week3's position1 is the song with index x in the [song] table.
-
The best way would be to structure the table so that your Outlaw41 table contains the unique index values from the Song table rather than the song titles.
-
having neber used mysql, this is all i can suggest...
http://www.mysql.com/doc/M/E/MERGE.html
[edit]but yes, moose is right. make sure you have identical keys in both tables and (i'm thinking of M$ access right now) there should be an option to link one to another. i'll have to dl mysql. i've been making the slow move away from M$ anyhow.[/edit]