turingschool / curriculum

Turing's main repository of tutorials and projects
385 stars 501 forks source link

Clarification needed in Traffic_Spy #1026

Open Jwan622 opened 9 years ago

Jwan622 commented 9 years ago

Hey jumpstart team!

I would love clarification on this section of the tutorial. Where do I type in Sequel.as(:column, :alias)?

Is my tables are :urls, :payloads and say I have an "id" column in both, how do I join the two tables together without the values of :payloads overwriting the values of :urls?

table = DB.from(:payloads) table.join(:urls, :id => :url_id)

How do I alias so that :id is named something else in the new joined together table?

"One word of caution. If the tables you are joining have the same column names, the join method will put the data from the second table into the matching columns of the first table in the resulting dataset. To prevent this, use Aliasing.

Sequel.as(:column, :alias)

The syntax in Sequel also allows for implicit aliasing in column symbols using the triple underscore:

:columnalias # "column" AS "alias" or :tablecolumn__alias # "table"."column" AS "alias""

jcasimir commented 9 years ago

What's your question?