Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do you do multiple SQL statements in one mysql_query?

Tags:

People also ask

How do I run multiple SQL statements in one query?

To run a query with multiple statements, ensure that each statement is separated by a semicolon; then set the DSQEC_RUN_MQ global variable to 1 and run the query. When the variable is set to zero, all statements after the first semicolon are ignored.

Can two statements run in one SQL script?

You can just run multiple SQL statements one after the other in a stored procedure.

Can you have multiple from statements in SQL?

A simple SELECT statement is the most basic way to query multiple tables. You can call more than one table in the FROM clause to combine results from multiple tables.


Say I wanted to do UPDATE table SET name = 'bob' and UPDATE table SET age = 55 WHERE name = 'jim' how do I do them in the same mysql_query()?

EDIT: Since this question has a fair amount of views I'd like to point out that as of PHP 5.5 mysql_query and other mysql_* functions are now deprecated and shouldn't be used.