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

Rasbin Rijal
PLUS
Rasbin Rijal
Courses Plus Student 10,863 Points

Concatenate first_name and last_name in mysql

Hi There,

I could not pass task 3. Need some help

Select the first letter of the "first_name", followed by a period, followed by a space and then add the "last_name". Also, convert "last_name" to upper case. Alias it as "name". Here's an example: "A. CHALKLEY". The name of the table is "users". Here is my code

  CONCAT(SUBSTRING(first_name, 1, 1), ".", " ", UPPER (last_name);

Thank you

1 Answer

Steven Parker
Steven Parker
215,972 Points

You did good so far, but you still have a few steps left:

  • check for missing/mismatched parentheses
  • alias the result of your CONCAT as "name"
  • put all that in a SELECT statement
  • remember to add the FROM clause identifying the users table to complete the SELECT statement
Rasbin Rijal
Rasbin Rijal
Courses Plus Student 10,863 Points

Steven Parker Thank you. But, Still it displays this error "You should try writing a select statement." Something is wrong with my syntax.

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

Steven Parker
Steven Parker
215,972 Points

This time it looks like you have it right. I have no idea why it would not be accepted.

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

Try it again?

BTW, I would normally pre-join adjacent literals into one argument, like this:

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

But either way produces the same output (and should pass the challenge).