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 trialKiki Y
Courses Plus Student 492 PointsHow to solve address format for the challenge?
I am confident that my syntax is correct for the address format. But it kept telling me that my format is wrong. What's wrong?
SELECT street AS Street, city AS City, State AS State, zip AS Zip, country AS Country, Street||", "||City||", "||State||" "||Zip||". "||Country||". " AS address FROM addresses;
2 Answers
jcorum
71,830 PointsThen it would be more like this:
SELECT street || ", " || city || ", " || state || ", " || zip || ". " || country || ". " AS 'Address' FROM addresses;
You had a final period after country, but in your later example you don't. I left it in the above SQL. If not, then:
SELECT street AS 'Street', city AS 'City', State AS 'State', zip AS 'Zip', country AS 'Country', street || ", " || city || ", " || state || " " || zip || ", " || country AS 'Address' FROM addresses;
You have a comma after state here:
34 NE 12 st, Portland, OR, 97129. USA
but not here:
(Street, City, State Zip. Country)
So you may have to adjust if the former is the correct version.
Also, this SQL assumes they wanted an alias for the whole thing of Address
jcorum
71,830 PointsIt would help if you gave a link to the challenge so I could test this, but (1) aliases must be text, (2) you can't use aliases as fields, (3) you should leave spaces before and after operators like ||, and (3) they probably wanted a comma after zip rather than a period:
SELECT street AS 'Street', city AS 'City', State AS 'State', zip AS 'Zip', country AS 'Country', street || ", " || city || ", " || state || " " || zip || ", " || country || ". " AS 'Address' FROM addresses;
This assumes there is an addresses table
Kiki Y
Courses Plus Student 492 PointsThe format needs to be:
34 NE 12 st, Portland, OR, 97129. USA (Street, City, State Zip. Country)
Thank you.