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

Slightly confused with the SUBSTRING clause in my MySQL command.

The task says:

"Select the first letter of the "first_name", add a period after it, followed by a space and add the "last_name". Also, convert "last_name" to upper case. Call it "name". Example: "A. CHALKLEY"."

And my code is as follows:

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

I'm rather confused with how to combat this situation, so any help would be greatly appreciated

2 Answers

The number 1 should be within the parenthesis with an additional 1 to tell it where to end. Also, don't forget to close all of your parenthesis. Everything else looks good though. Oh and of course don't forget to punctuate it at the end with a semicolon.

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

Thank you very much Jeremy. I got confused with all the parentheses etc, so thanks for clarifying that for me :)

Thanks for this! I kept thinking (SUBSTRING(first_name)1, could work!

Kas Verm
Kas Verm
1,664 Points

This also works and takes a few less characters:

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