Connecting Tech Pros Worldwide Forums | Help | Site Map

mysql syntax

Member
 
Join Date: May 2007
Posts: 102
#1: Jun 22 '07
insert into A (name) values(rsReport.fields("name")) ??? is this syntax correct?

code green's Avatar
Expert
 
Join Date: Mar 2007
Location: England
Posts: 1,080
#2: Jun 22 '07

re: mysql syntax


Expand|Select|Wrap|Line Numbers
  1. INSERT INTO `table_name` (`field1`,`field2`,etc) VALUES ( 'value1','value2','etc)
savanm's Avatar
Member
 
Join Date: Oct 2006
Location: chennai
Posts: 86
#3: Jun 23 '07

re: mysql syntax


INSERT INTO 'tablename' VALUES ('value1','value2'.....);

forexample:

insert into data (firstname,lastname,age) values ('bas','sab',21)

if u want to insert only two field means

insert into data (firstname,age) values ('baas',21)

if u want to insert all field means

insert into data values('das','sad',24)
Atli's Avatar
Moderator
 
Join Date: Nov 2006
Location: Iceland
Posts: 3,751
#4: Jun 23 '07

re: mysql syntax


Quote:

Originally Posted by lyealain

insert into A (name) values(rsReport.fields("name")) ??? is this syntax correct?

Where does the 'rsReport' come from?

The value you specified is not valid SQL syntax no, but if you are trying to build a query in some coding language or a script then this is pretty close.

The previous replies explained how MySQL expects a INSERT query to be formatted, so its just a matter of getting you code to create it correctly.

P.S.
Quote:

Originally Posted by savanm

if u want to insert all field means

insert into data values('das','sad',24)

This is true, it is however good practice to always specify the columns you want to insert into. This will ensure that your queries will work, even if at some point the table layout is altered.
Reply