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
Charles Gray
19,470 PointsSelect the "first_name" followed by the username in parentheses and alias it as "display_name". For example "Andrew (chalkers)". There's a space between the end of the first_name and username in parentheses.
clearly there's something wrong with this challenge. I tried to use this statement:: SELECT CONCAT(first_name," ", (username)) AS display_name FROM users
9 Answers
Hunter MacDermut
15,865 PointsYou need to explicitly concatenate the parenthesis, like so:
SELECT CONCAT(first_name, " ", "(", username, ")") AS display_name FROM users;
Christy Hong
1,478 Pointsthis one passed:
SELECT CONCAT(SUBSTRING(UPPER(first_name),1,1), ". ", UPPER(last_name)) AS name FROM users;
Charles Gray
19,470 PointsThanks I just figured that out 30 mins ago, I appreciate it. I'm stuck on the third challenge now, do you have any idea how to do that one?
Hunter MacDermut
15,865 PointsVery similar to the 2nd challenge. You'll need to make use of the SUBSTRING function. It takes 3 arguments: the string you wish to take a substring from, the start index, the end index. Remember that SQL uses 1-based indexing, not 0 like many other languages. You'll also need the UPPER function in there.
Charles Gray
19,470 PointsOk I'll try it out and see what I come up with, thanks.
Zac Painter
7,125 PointsSELECT CONCAT(SUBSTRING((first_name).1),".", (UPPER(last_name))) AS name FROM users;
I've had the same problem with the third question to this challenge. I'm not sure if I am putting the extra period in the correct spot. My code is above.
Brian Bush
4,398 Pointsyou are missing an arg in your SUBSRTING, and you need to CONCAT 1 more thing. Other than that everything is good!
Brian Bush
4,398 Pointsalso use a , instead of a . when defining args in SUBSTRING
Brian Bush
4,398 Pointsand you have 2 extra pairs of ( ). sorry I would have this all in one comment but it wouldnt let me edit my first comment
Zac Painter
7,125 PointsThat's fine, I got through it. Thanks!
shahardekel
20,306 PointsIt seems that
SELECT CONCAT(first_name, " (", username, ")") AS disply_name FROM users;
gives the correct answer but is not an acceptable answer for some reason. It simply users 3 parameters for the CONCAT function instead of 4.
David Jones
1,635 Pointscan someone explain why we need to use " " two times here for username as Im not clear
(first_name, " ", "(", username, ")")
I was trying it as (first_name, " ", "( username)") and I dont know why that doesntwork
thanks
shahardekel
20,306 PointsDavid, from my understanding, it's because you cannot combine row names (like first_name or username) with actual strings (like space " ") so you have to concatenate them. When you want to use data from the database, you use the row name and you concat a string wrapped with double quotes.