What SQL command can i use to solve the following dilemma?

Tushar Devi :

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!

Mureinik :

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]

編集
0

コメントを追加

0

関連記事

分類Dev

What does the following JavaScript function do and what can I use it for?

分類Dev

Can I still use parameters for sql command?

分類Dev

What Docker command can I use after login to Docker registry?

分類Dev

How can I solve this new error on the command line?

分類Dev

How can I use the following formula to determine the value of a variable?

分類Dev

how can i write this sql according to the following criteria

分類Dev

Can I use FOR /L counter variable in the FOR command?

分類Dev

How can I change my following quick sort code so that I can use randomized pivot?

分類Dev

Can I use temporary value in sql query

分類Dev

How can I use the command "pwd" in R to load data?

分類Dev

Is there a command that I can use to send messages to other people in discord rewrite?

分類Dev

How can I use two bash commands in -exec of find command?

分類Dev

How can I use the previous command's output?

分類Dev

I can't use the ./ command in USB flash drive

分類Dev

How can i convert this sql query in a eloquent laravel command?

分類Dev

How can i solve the error when running xampp saying that the port/s are in use by another program?

分類Dev

how can i solve this error, javax.servlet.ServletException: java.sql.SQLException: No database selected

分類Dev

What are Launchpad packaging recipes and how can I use them?

分類Dev

What is the Addr# type, and how can I use it?

分類Dev

What Kubernetes API endpoint can I use to see if there are unscheduled pods?

分類Dev

What is a more accurate algorithm I can use to calculate the sine of a number?

分類Dev

What tools and techniques can I use to make GTK themes?

分類Dev

What type can I use to represent the __Renderings field in a Glass model?

分類Dev

What kind of files I can use in GitHub Pages?

分類Dev

What language(s) can I use in LibreOffice for macro scripting?

分類Dev

What program can I use to convert text into binary numbers?

分類Dev

What datatype should I use for saving a file in a SQL Azure database?

分類Dev

What technique should I use for Optimizing the SQL Query

分類Dev

Unable to use an environment variable in command prompt, even though I can print it's value using echo command

Related 関連記事

  1. 1

    What does the following JavaScript function do and what can I use it for?

  2. 2

    Can I still use parameters for sql command?

  3. 3

    What Docker command can I use after login to Docker registry?

  4. 4

    How can I solve this new error on the command line?

  5. 5

    How can I use the following formula to determine the value of a variable?

  6. 6

    how can i write this sql according to the following criteria

  7. 7

    Can I use FOR /L counter variable in the FOR command?

  8. 8

    How can I change my following quick sort code so that I can use randomized pivot?

  9. 9

    Can I use temporary value in sql query

  10. 10

    How can I use the command "pwd" in R to load data?

  11. 11

    Is there a command that I can use to send messages to other people in discord rewrite?

  12. 12

    How can I use two bash commands in -exec of find command?

  13. 13

    How can I use the previous command's output?

  14. 14

    I can't use the ./ command in USB flash drive

  15. 15

    How can i convert this sql query in a eloquent laravel command?

  16. 16

    How can i solve the error when running xampp saying that the port/s are in use by another program?

  17. 17

    how can i solve this error, javax.servlet.ServletException: java.sql.SQLException: No database selected

  18. 18

    What are Launchpad packaging recipes and how can I use them?

  19. 19

    What is the Addr# type, and how can I use it?

  20. 20

    What Kubernetes API endpoint can I use to see if there are unscheduled pods?

  21. 21

    What is a more accurate algorithm I can use to calculate the sine of a number?

  22. 22

    What tools and techniques can I use to make GTK themes?

  23. 23

    What type can I use to represent the __Renderings field in a Glass model?

  24. 24

    What kind of files I can use in GitHub Pages?

  25. 25

    What language(s) can I use in LibreOffice for macro scripting?

  26. 26

    What program can I use to convert text into binary numbers?

  27. 27

    What datatype should I use for saving a file in a SQL Azure database?

  28. 28

    What technique should I use for Optimizing the SQL Query

  29. 29

    Unable to use an environment variable in command prompt, even though I can print it's value using echo command

ホットタグ

アーカイブ