+ 1

Mysql query

I used double quotes on date and time in my query and my professor is saying that date and time needs single quote. Would a double quote give an error? INSERT INTO Bookings ( user_id, room_id, date, start, end, purpose) VALUES ( 5, 20, "2020-08-26","7:00 PM", "9:00 PM", "CS 215 final exam");

30th Aug 2020, 1:35 AM
Vrushti Patel
Vrushti Patel - avatar
3 Antworten
+ 2
It probably won't produce an error, but double quotes is not typical SQL convention. "Single quotes are used to indicate the beginning and end of a string in SQL. Double quotes generally aren't used in SQL, but that can vary from database to database. Stick to using single quotes" https://discuss.codecademy.com/t/whats-the-difference-between-single-quote-and-double-quote-in-sql-query/268730
30th Aug 2020, 1:55 AM
Steven M
Steven M - avatar
+ 1
insert into Bookings('user_id',....'purpose')values(......); we use backquote not single or double quotes to indicate the columns of a table.
30th Aug 2020, 9:53 AM
HBhZ_C
HBhZ_C - avatar