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

Juner Pagal
Juner Pagal
11,968 Points

What is wrong of my code? SELECT CONCAT(first_name." (".username.")". ) AS display_name FROM users;

What is wrong of the below code.

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

3 Answers

Jonathan Grieve
MOD
Jonathan Grieve
Treehouse Moderator 91,253 Points
SELECT CONCAT(first_name . " (". username .")" ) AS display_name FROM users;

This one should pass if the above one hasn't. It simply removes a space from the end of the string closing bracket. Let me know if still stuck :)

Juner Pagal
Juner Pagal
11,968 Points

Im still stuck.

Bummer! There's something wrong with your query.

Juner Pagal
Juner Pagal
11,968 Points

Thanks Jonathan for your time helping with this. I got the correct answer below. It must be comma and not period to be used for concatenation.

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

Jonathan Grieve
MOD
Jonathan Grieve
Treehouse Moderator 91,253 Points

It looks like a simple issue with incorrect string concatenation. You included the last closing bracket but it doesn't need concatenating rather it is simply closing the concat function.

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

Have a look at the example output the question has given you; i'm assuming it has and compare it to the code output above. :-)

Juner Pagal
Juner Pagal
11,968 Points

Hello Jonathan

Here's the question: Select the "first_name" concatenated with the username in parentheses and alias it as "display_name". For example "Andrew (chalkers)". Note that there's a space between the end of the first_name and username in parentheses. The name of the table is "users".

Thanks,

Jonathan Grieve
Jonathan Grieve
Treehouse Moderator 91,253 Points

It might just be a syntax error as I believe Code challenges and the playground on Treehouse use SQLite syntax for SQL.

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


SELECT first_name ||  " (" || username || ") "  AS display_name FROM users;

If any of these are not the issue I'm stumped. Perhaps you could link to the playground or code challenge you're struggling with? )