Acees/SQL: Design simple database & query

Soldato
Joined
5 Dec 2003
Posts
2,716
Location
Glasgow
Hey, I've got a simple database with 2 tables, "users" and "courses" like this:

[Users]
username
password
courseID1
courseID2

[Courses]
courseID
coursename
credits
signups

And I want to run a query to get the details for the 2 courses that a given username has signed up for. Does anyone know how I would do this? Or what the SQL is for it? Do I need to change the database at all? I just made it quickly and to be honest, I remember little about using databases as it's been ages since I worked on any.
 
SELECT c1.coursename, c2.coursename, u.username
from courses c1, courses c2, users u
where u.courseID1 = c1.courseID
and u.courseID2 = c2.courseID;
 
Back
Top Bottom