I am creating a small database where a user can store all his workouts. I have the following tables in my database:
UserTable(Username, Name)
, where Username
is the primary key
exerciseTable(ExerciseID, ExName)
where ExerciseID
is the primary Key,
WorkoutTable(WorkoutID, Username, Wdate, ExerciseID)
, where WorkoutID
is the primary key and ExerciseID
and username are the foreign keys.
I would like to output the date
and the ExName
for a specific user.
SELECT Wdate, ExerciseID
FROM WorkoutTable
WHERE Username = 'tushardev1'
This code will output the date
and the ExerciseID
. However, I do not want the exerciseID
but the ExerciseName
next with the Date
. What command do I need to write to solve this problem?
Thanks for the help!
You could join on the ExerciseTable
:
SELECT Wdate, ExName
FROM WorkoutTable w
JOIN ExcerciseTable e ON w.ExcerciseId = e.ExcerciseId
WHERE username = 'tushardev1'
この記事はインターネットから収集されたものであり、転載の際にはソースを示してください。
侵害の場合は、連絡してください[email protected]
コメントを追加