Welcome to WebmasterWorld Guest from 54.205.119.93

Forum Moderators: coopster & jatar k

Message Too Old, No Replies

Help me on Mysql

   
6:31 pm on Jun 12, 2005 (gmt 0)

10+ Year Member



I have this code,

INSERT INTO `newbus` ( 'busid' )
VALUES (
'3'
)

And i got this error message,
You have an error in your SQL syntax. Check the manual that corresponds to your MySQL server version for the right syntax to use near ''busid' ) VALUES (
'3'
)' at line 1

What seems to be the problem? Thanks

6:37 pm on Jun 12, 2005 (gmt 0)

10+ Year Member



Try it without using quotes for table/column names:

INSERT INTO newbus (busid) VALUES ('3');

If busid is a numeric column, also remove the quotes from '3':

INSERT INTO newbus (busid) VALUES (3);

6:40 pm on Jun 12, 2005 (gmt 0)



Have you tried to put a ; (semicolon) at thee end of the statement?

The way you do the statement (the pattern) is like this:

Insert into table_name
(columnName1, ColumnName2, ...)
Values (Value1, Value2, ...);

6:41 pm on Jun 12, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Your column names don't need to be quoted. If you want/need to quote the column names, use the back tick(`) instead.

INSERT INTO `newbus` ( busid )
VALUES (
'3'
)

or

INSERT INTO `newbus` ( `busid` )
VALUES (
'3'
)

Cheers

2:10 am on Jun 13, 2005 (gmt 0)

10+ Year Member



Thanks, now i know my mistake. My eyes are not realy good in differentiating ( ' ) and ( ` ).
 

Featured Threads

Hot Threads This Week

Hot Threads This Month