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 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.