Pankaj Yadav
Pankaj Yadav

Reputation: 37

Syntax error in SQL query unable to understand

I'm getting a syntax error: Syntax error near 17:38

insert into tbl_otp('mobile', 'otp', 'exp') values (9932111111, 333333, 2019-04-09 17:38:34)

Upvotes: 0

Views: 68

Answers (3)

hd1
hd1

Reputation: 34677

insert into tbl_otp(`mobile`, `otp`, `exp`) 
values ('9932111111', '333333', '2019-04-09 17:38:34')

Need to backquote your column names and single-quote your values, though the latter is just to be safe.

Upvotes: 1

JD D
JD D

Reputation: 8147

put the date value in quotes and remove quotes from column names:

insert into tbl_otp(mobile, otp, exp) values (9932111111, 333333, '2019-04-09 17:38:34')

Upvotes: 0

Mureinik
Mureinik

Reputation: 312259

Single quotes denote string literals, so you shouldn't use them for column names. You should, however, surround the date literal with quotes:

insert into
tbl_otp(mobile, otp, exp) -- no quotes
values (9932111111, 333333, '2019-04-09 17:38:34') -- quotes

Upvotes: 3

Related Questions