Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Databases Reporting with SQL Working with Text Concatenating Text

Takyi Akwah
PLUS
Takyi Akwah
Courses Plus Student 1,049 Points

Concatenation Challenge Help

In the library database there's a patrons table listing all the users of the library. The columns are id, first_name, last_name, address, email, library_id and zip_code.

Generate a list of strings that are in the following format: Andrew Chalkley andrew@teamtreehouse.com. Concatenate the first name, last name and email address for all users.

Alias it to to_field. This will be used in the "To" field in email marketing.

Type in your command below, then press Ctrl-Enter.

Bummer: Your query needs didn't retireve the emails in the correct format.

To

SELECT first_name || " " || last_name || " " || email FROM patrons AS "to_field";

Where am I going wrong?

2 Answers

Jennifer Nordell
seal-mask
STAFF
.a{fill-rule:evenodd;}techdegree
Jennifer Nordell
Treehouse Teacher

Hi there! There are a couple of issues here. The first problem is that you have your alias in the wrong spot. The second problem is what I believe is a misunderstanding of the instructions. It actually wants those emails inside the angle brackets which means they also need to be concatenated. The alias should come before the FROM patrons. This is how I solved it:

SELECT first_name || " " || last_name || " <" || email || ">" AS "to_field" FROM patrons;

If the first name is "Jennifer", the last name is "Nordell" and the email is "me@example.com", then this will print out "Jennifer Nordell <me@example.com>" complete with the angle brackets inside the "to_field".

Hope this helps! :sparkles:

Takyi Akwah
Takyi Akwah
Courses Plus Student 1,049 Points

Thank you for the help.

Now I cannot pass the second challenge.

Please see below and show me my error:

In an ecommerce database there's a addresses table. There is an id, nickname, street, city, state, zip, country and user_id columns.

Concatenate the street, city, state, zip and country in the following format. Street, City, State Zip. Country e.g. 34 NE 12 st, Portland, OR 97129. USA

Alias the concatenated string as address

Type in your command below, then press Ctrl-Enter.

Bummer: There's something wrong with your SQL statement. Please review your code and try again.

SELECT street || ", " || city || ", " || state || " " || zip || ". " || country AS address FROM adresses;

Jennifer Nordell
seal-mask
.a{fill-rule:evenodd;}techdegree
Jennifer Nordell
Treehouse Teacher

Takyi Akwah this time it's simply a typo in the table you're selecting from. You've told it to select from the adresses table, but you meant from the addresses table. Note the two "d"s in the latter version :smiley: