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?
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""
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""