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 trialJoe Hilton
Courses Plus Student 4,893 PointsCan anyone point me in the right direction as to what's wrong with my MySQL code please
So the task says: "Select 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."
And my MySQL command is this:
"SELECT CONCAT(first_name, " " , (username)) As display_name FROM users"
It's displaying the table but it keeps saying that something is wrong but I can't quite put my finger on it.
4 Answers
Justin Horner
Treehouse Guest TeacherHello Joe,
You're almost there!
To include the username inside of parenthesis using the variables you've provided, the code would look something like this. We need to add the parenthesis as strings to the CONCAT function with the username variable in the center.
SELECT CONCAT(first_name, ' (', username, ')') AS display_name FROM users
I hope this helps.
Chris Vukin
17,787 PointsThe instructor should cover using these special characters like in the exercises. It does no one any good to throw in untaught material to challenges, this is not a proper education technique. We might as well just do all our learning by googling huh? But that's not why we pay for the courses.
Sreng Hong
15,083 PointsHi Joe, I think you can't do (username)
, but I'm not so sure about that.
I found out another way to pass this challenge
select concat(first_name," (",username,")") as display_name from users;
Amin Khoshzahmat
12,342 PointsTHIS IS YOUR ANSWER
SELECT CONCAT( first_name," (",username,")" ) AS display_name FROM users;
Joe Hilton
Courses Plus Student 4,893 PointsJoe Hilton
Courses Plus Student 4,893 PointsHi Justin, this was correct thanks :)
Justin Horner
Treehouse Guest TeacherJustin Horner
Treehouse Guest TeacherYou're welcome!
Anna Takang Nchongarrey-Oben
7,365 PointsAnna Takang Nchongarrey-Oben
7,365 Pointsthanks a lot.
Anna Takang Nchongarrey-Oben
7,365 PointsAnna Takang Nchongarrey-Oben
7,365 Pointsthanks a lot.