Bummer! You have been redirected as the page you requested could not be found.

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

PHP

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.

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

You need to explicitly concatenate the parenthesis, like so:

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

this one passed:

SELECT CONCAT(SUBSTRING(UPPER(first_name),1,1), ". ", UPPER(last_name)) AS name FROM users;

Thanks 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?

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

Ok I'll try it out and see what I come up with, thanks.

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

you are missing an arg in your SUBSRTING, and you need to CONCAT 1 more thing. Other than that everything is good!

also use a , instead of a . when defining args in SUBSTRING

and you have 2 extra pairs of ( ). sorry I would have this all in one comment but it wouldnt let me edit my first comment

That's fine, I got through it. Thanks!

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

can 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

David, 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.