Questions tagged [multi-query]

Used for running multiple database queries/statements. Such as, queries separated by a semi-colon ';' in SQL. Or running multiple queries via separate requests.

SQL Example:

SELECT * FROM table1;
SELECT * FROM table2;

PHP/mysqli example1:

mysqli_multi_query(
    "SELECT * FROM table1;
     SELECT * FROM table2;"
);

PHP/mysqli example2:
This isn't really good practice, compared to the previous example, but this tag would still be fitting for a question with this type of code.

   mysqli_query("SELECT * FROM table1");
   mysqli_query("SELECT * FROM table2");

However, for PHP/mysqli, you should use mysqli-multi-query

84 questions
0
votes
2 answers

Databricks SQL Connector for Python - How to execute Multiple Queries?

I can successfully execute each query individually, and can run multiple in the databricks environment, However I can not get it to work for a multi-query statement through Databricks SQL Connector for Python. Piece of the python below; query =…
kmaclean
  • 3
  • 1
0
votes
1 answer

Stack query results in one query result so the order of rows depends on which part returns which result

What I would like to know is, if you could take two queries and get them orderly represented in one resultset. So in example we take two queries: Select a.col1, a.col2 from a where a.col3 = 1 Order By a.col2 and Select a.col1, a.col2 from a where…
user16025262
0
votes
3 answers

mysql split multiquery string with php

I want to make a database restore function that will parse a dump made with phpMyAdmin and will execute all of the queries. I already have a MySQL class that does the query, but it only knows how to do a single query. I am looking of a way to split…
Gabriel Solomon
  • 29,065
  • 15
  • 57
  • 79
0
votes
1 answer

Is there an equivalent for MySQL's "multi_query()" in PDO?

I like assembling multiple SQL queries into one string and executing them simultaneously to ensure that they are executed atomically. I can't seem to do this with PDO like I could with the MySQL functions though. Any thoughts?
Hubro
  • 56,214
  • 69
  • 228
  • 381
0
votes
0 answers

Update multi query by multiple instances of a service leads to deadlock in mysql

I have a service that runs an update multi query update hits set hits = hits + 1 where id = x. I found out that running multiple instances of this service throws error Error 1213: Deadlock found when trying to get lock; try restarting transaction. I…
0
votes
0 answers

How to execute multiple queries in oracle

Good morning. I am making a function that connects to Oracle from JDBC and executes a query. The number of query statements to be executed is about 50. I looked for several examples, but most of them are examples that execute only one, and even this…
user13746660
0
votes
1 answer

Search Engine with Multiple Qualification Filters in SQL Server

I am trying to build a search engine like the ones Job portals have. My query is particularly related to qualification. My end user may query for employees who have a single or set of qualification-discipline combinations, or they may give a list of…
0
votes
0 answers

php: how to run several php multi_query statement

I need to understand how the MySQLi multi_query() works. I'm working on table 'stefano' with (unique) field 'f1'. If I run multi_query( "insert into playground.stefano (f1) values ('a'); insert into playground.stefano (f1) values…
Stefano Radaelli
  • 1,088
  • 2
  • 15
  • 35
0
votes
2 answers

MySQL multiquery gives errors, need to save variable

I have a table where I need to do two selections. First I need to find OBJ where uunn = abc. Then I need to select where OBJ equals the first result but it doesn't work. Example: SELECT OBJ INTO @obj FROM wddt WHERE `uunn`='abc' AND…
Sander
  • 23
  • 7
0
votes
1 answer

Process Multiple Row by a MYSQL Store Procedure

I am facing some trouble inserting data into a table by Store Procedure. Please allow me to explain in details. I have a Three tables CREATE TABLE `table_1` ( `id` INT(11) NOT NULL AUTO_INCREMENT, `s_id` INT(11) NOT NULL, `created` DATE…
Jhilom
  • 1,028
  • 2
  • 15
  • 33
0
votes
1 answer

mysql LAST_INSERT_ID not working through php

I tried two ways for reaching it this job: multi_query: $sql = "START TRANSACTION; INSERT INTO songs (title, disco, deleted) VALUES ('".$titol."', '".$codi."', '0'); SET @last_id = LAST_INSERT_ID(); INSERT INTO lyrics (`lyricsOri`, `lyricsTra`,…
jDoe
  • 13
  • 4
0
votes
3 answers

Merge two SELECT statements with different data types and number of columns into one output in PostgreSQL

I have two queries. The first - SELECT communications.creation_date as message_date, message as message_text, employees.first_name || ' ' || coalesce(employees.middle_name,'') || ' ' || employees.last_name as message_by FROM…
Clint_A
  • 518
  • 2
  • 11
  • 35
0
votes
2 answers

MySQLi Multi Query doesn't work

Good morning, I am trying to use MySqli Multi-query to put variables that are posted by the login script in two different database tables; the common details need to be posted in the wp_users table, and the uncommon details need to be posted in the…
J. Valckx
  • 5
  • 1
0
votes
1 answer

How to retrieve multiple columns count with different where clause?

I need to construct the following table.