Questions | Login

Top / PHP / MySQL

please help question mysql!!!?

demo 17 Dec 2008 08:07am
hi, Im learning sql and not sure how to do this?

Iam on INSERT INTO tables.

Can I insert more that one persons name, age, title, ect...into the table at one time? Every time I try it wont work?


exmaple: I want to insert these name, age, title at ONE time :

neecey ,producer,40
alan ,baker,30
mark, designer,25
sally, sales, 25



can you show me how to do this if thats possible ? thanks!!

Answers

demo 17 Dec 2008 08:31am
Unless your DBMS has a load utility (which MySQL does not AFAIK) and you have the insert values in a csv or similar format file, you have to insert each one separately.
demo 17 Dec 2008 08:39am
I believe it can be done, at least in MySQL:
INSERT INTO tables (name,title,age)
VALUES("neecey", "producer", 40),
("alan", "baker", 30),
("mark", "designer", 25),
("sally", "sales", 25);


Here's the URL that proves it:
http://dev.mysql.com/doc/refman/5.1/en/insert.html
demo 17 Dec 2008 08:45am
YES, other answers are incorrect.
MYSQL synthax supports multiple single line inserts.
Your sql would be:
INSERT INTO table(name,title,age)
VALUES ('neecey','proucer',40) , ('alan','baker',30), ('mark','designer', 25), ('sally','sales',25) ;

Related

Submit Answer

You must be logged in to post an answer. Please Login or Register.

Powered by phpMyAnswers.