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

Databases

Rasbin Rijal
PLUS
Rasbin Rijal
Courses Plus Student 10,864 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
229,644 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,864 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
229,644 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).