Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

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 90,705 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 90,705 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 90,705 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? )