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 Securing and Maintaining a MySQL Database Indexing Columns in MySQL

Cecilie Johnsen
Cecilie Johnsen
1,694 Points

Single or double quotes in MySQL

What is the difference between single quotes and double quotes in SQL? I've learned that you should stick to using single quotes, but it can vary from database to database.

1 Answer

Konstantinos Pedarakis
Konstantinos Pedarakis
21,301 Points

Hi Cecilie Johnsen

Actually there is no difference between the two. You can store string with single and double quotes. But... single quotes are used to indicate the beginning and end of a string in SQL. Double quotes generally aren't used in SQL, you use them in order to store lets say the whole SQL statement(query), in a variable so you can use it later in your code. As you correctly mention, yes you should stick to single quotes, in terms like when you want to indicate a string and not double. but you can do your job either way. Just another tip i can give you is that you should declare your tables and columns in lowercase. That way will be more convinient to you later when you use them inside your code. in PHP for example. Its easier to remember that you have all your fields in lowercase.