views:

54

answers:

1

Trying to create a simple 2 table database that lists the contents of various firewire drives, one table with FW number, the other with a file item on that drive number.

eg. fw 233 file -> mike's home movie.mov

I'm very new and can create single tables with queries, but haven't understood querying multiple tables with join.

each drive will have many files, and the point of this task is to learn, but really to have a living list of items on these drives, one that I can update frequently.

Any help would be great...

I'm using codeigniter and of course PHP

+2  A: 

You need to have a primary key on your Drive table and a foreign key on your File table.

Drive Table
-----------
DriveID
FWNumber
File Table
----------
DriveID
Filename

To see all of the files on DriveID 1 you would...

select Filename 
from File
where DriveID = 1
order by Filename
Alex
This is almost exactly what I had been typing up...Might want to add, though, that if you wanted to get all files with a particular FWNumber, your select would be:select File.FileName FROM File INNER JOIN Drive on Drive.DriveID = File.DriveIDWHERE Drive.FWNumber = 233
Steve Danner