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 trialJoe Hilton
Courses Plus Student 4,893 PointsSlightly 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
J Donahue
30,790 PointsThe 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;
Kas Verm
1,664 PointsThis also works and takes a few less characters:
SELECT CONCAT(SUBSTRING(first_name,1,1), ". ", UPPER(last_name)) AS name FROM users;
Joe Hilton
Courses Plus Student 4,893 PointsJoe Hilton
Courses Plus Student 4,893 PointsThank you very much Jeremy. I got confused with all the parentheses etc, so thanks for clarifying that for me :)
Jim Withington
12,025 PointsJim Withington
12,025 PointsThanks for this! I kept thinking
(SUBSTRING(first_name)1,
could work!