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 Database Foundations SQL Calculating, Aggregating and Other Functions String Functions

Can 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
STAFF
Justin Horner
Treehouse Guest Teacher

Hello 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.

Hi Justin, this was correct thanks :)

Chris Vukin
Chris Vukin
17,787 Points

The 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
Sreng Hong
15,083 Points

Hi 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;

THIS IS YOUR ANSWER

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