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 Reading Data from Databases with SQL Retrieving a Result Set

Sreng Hong
Sreng Hong
15,083 Points

Should the query statement write in uppercase or lowercase?

I wonder why we should write the query statement in uppercase. Is it the best practice or something?

I think the both lowercase and uppercase query statement return the same result.

2 Answers

Carter Meyers
Carter Meyers
3,236 Points

While the SQL keywords you're referring to are case-insensitive (FROM, SELECT, WHERE, ON, IN, AS, etc.), it is indeed common practice to capitalize these words. Combined with proper spacing and indenting, this practice will make your SQL statements much easier to read and refer back to later on.

Note: Unlike SQL keywords, table and database names are NOT case-insensitive. These require proper capitalization on most platforms you'll use.

If I'm just running a SQL query for myself on the fly, I don't tend to bother capitalising but if I'm writing something more formal like a report, I always capitalise the keywords and use all the correct spacing/indenting etc.