Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

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.