buschbirk / intro-data-capstone-musclehub

0 stars 0 forks source link

Make your life easier with aliases #3

Closed hillarygreenlerman closed 6 years ago

hillarygreenlerman commented 6 years ago

https://github.com/buschbirk/intro-data-capstone-musclehub/blob/66253a292dbe1c2e164ec5b57ff40c1a6da26ecf/Final%20Analysis/musclehub.py#L127

Typing out fitness_test multiple times is a pain. You can make your life easier by aliasing each table with something shorter, like ft.

Here's an example:

SELECT v.first_name,
    ft.fitness_test_date,
    p.purchase_date
FROM visits v
LEFT JOIN fitness_tests ft
    ON ft.first_name = v.last_name
    AND ft.last_name = v.last_name
...
buschbirk commented 6 years ago

Didn't know you could alias the whole table! Cool :)