Multiple Query Statement

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
r_barlow
Forum Newbie
Posts: 17
Joined: Mon May 29, 2006 3:13 pm

Multiple Query Statement

Post by r_barlow »

Hey,

Is there a way to string together multiple queries into one statement?

Ex:

-------------
INSERT INTO news (article, date) VALUES ('blah blah', CURDATE());

INSERT INTO news (article, date) VALUES ('blah blah blah', CURDATE());
-------------

In Query Browser you have to execute each line separately. When I try to execute something like this using mysql_query I get an error. I would have thought that since the line is ended with a ";" I'd be able to.
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

mysql_query() only supports a single query at a time. MySQLi has multi-query support. However, MySQL supports extended inserts.

A little below on this page shows how extended inserts work.
Post Reply