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

Development Tools

Cannot pass 'String Functions' code challenge task 2 of 3 from SQL Calculating, Aggregating and Other Functions

I can't for the life of me get this question right, have tried everything...

1 Answer

Okay, so you have to grab two things from the DB, format them in a certain way and then alias that selection.

This is what you do. You SELECT the first_name and username and use the CONCAT function to concatenate the strings in this format: Name (username).

SELECT CONCAT(first_name, " (", username, ")") AS display_name FROM users;

You concatenate the first name with a space followed by the opening parenthesis, then the username and then the closing parenthesis. You alias it as display_name and finally specify which table you're selecting from.