Welcome to WebmasterWorld Guest from 54.196.217.43

Forum Moderators: coopster & jatar k

Message Too Old, No Replies

Help me on Mysql

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

Full Member

10+ Year Member

joined:May 4, 2005
posts:306
votes: 0


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 June 12, 2005 (gmt 0)

Preferred Member

10+ Year Member

joined:Feb 16, 2005
posts:456
votes: 0


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 June 12, 2005 (gmt 0)

Senior Member

joined:June 27, 2000
posts:1548
votes: 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 June 12, 2005 (gmt 0)

Senior Member

WebmasterWorld Senior Member 10+ Year Member

joined:Apr 22, 2002
posts:2546
votes: 0


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 June 13, 2005 (gmt 0)

Full Member

10+ Year Member

joined:May 4, 2005
posts:306
votes: 0


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