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
1
vote
1 answer

MySqli Error 2014 on new connection

when running the following code I encounter the error 2014:"Commands out of sync; you can't run this command now" $newConnection = new mysqli("127.0.0.1", username, password, "", 3306); $nativeQueryResult = $newConnection->multi_query ("SELECT…
1
vote
2 answers

sql combine two queries in one and SORT BY

I have a large table and I've built two queries to first query the first 2 columns and then the other columns. My intention obviously to put first 2 columns data on top then append the other columns's data below. Here is the query. SELECT * FROM…
inrob
  • 4,969
  • 11
  • 38
  • 51
1
vote
2 answers

Retrieve last_insert_id when performing multiple queries

I have read the MySQL-bug list, where I found out, that last_insert_id() returns the FIRST auto_increment-value when you're performing multiple insert statements. (Link: http://bugs.mysql.com/bug.php?id=34319) My problem is, that in my code, I…
denlau
  • 916
  • 2
  • 9
  • 21
1
vote
2 answers

PDO, fetchall and multiquery

Alright, I'm what i'm doing isn't possible the way i'm doing it (I've been up for two days straight... again) but is it possible to run a multiquery through PDO and return all the results... like so? $sql = "SELECT username, faction FROM users…
Gmz1023
  • 121
  • 11
1
vote
2 answers

How to get data with multiple references to single table

I have Image table with 3 columns: Id, Name, and RefId - It will contain Id from other table (with this example is Category table and Product table). Category table with 3 columns: Id, Name and ProductId. Product table includes 3 columns: Id,…
Hau Le
  • 667
  • 2
  • 17
  • 42
1
vote
1 answer

Improved way for multi-table SQL (MySQL) query?

Hoping you can help. I have three tables and would like to create a conditional query to make a subset based on a row's presence in one table then excluding the row from the results, then query a final, 3rd table. I thought this would be simple…
richkoru
  • 15
  • 4
1
vote
2 answers

Optimize my two queries in to one

I have two tables, one for keep track on chat statistics, and one for keeping track on mail statistics. My current queries are looking like this: SELECT COUNT(id) as chat_amount, DATE_FORMAT(timestamp, '%b %e') as period FROM tblChats WHERE…
1
vote
1 answer

Lazy Loading child collection with ToFuture

I'm currently using c# with Nhibernate 3.2 hitting a SqlServer database, and I am trying to work with multiquery's and Futures to load a child collection. Anyways I can get it to work using Linq to Nhibernate, but when viewing the sql is sent to the…
1
vote
2 answers

Checking is username exists on two tables PHP PDO?

I have a users table and a users_banlist table. On my registration form i want to check all in one query whether the username someone entered on form exists in the users table and see if it also exists on the users_banlist table. I can do them on…
PHPLOVER
  • 7,047
  • 18
  • 37
  • 54
0
votes
1 answer

Can use "Multiple MySQL Queries with PHP" with MySQL version 4

I can run multi-queries with MYSQL v5 with extension PHP :mysqli. But with MYSQL 4 with extension PHP: mysql .. with new query, have the problem. I would like to verify the information and the way to resolve. Because, the company hosting service is…
LTEHUB
  • 1,638
  • 1
  • 14
  • 17
0
votes
1 answer

NHibernate : load entire graph (collection of collection of collection)

I need (for a real good reason, trust me) to load what's almost the entire graph of my database using NHibernate. There are not so many entities, but the graph is kind of convoluted. My graph looks something like : EntityA | --> EntityB | -->…
0
votes
1 answer

Skip error and proceed execution of Mysqli::multi_query

Can I to skip errors and/or proceed execution of multi_query or I must to separate my big request and execute queries in query() individually? I execute such operators as CREATE VIEW, CREATE TABLE, CREATE PROCEDURE, etc. For example, I'm not very…
Guy Fawkes
  • 2,313
  • 2
  • 22
  • 39
0
votes
2 answers

How to set parameters on a Query in MultiQuery ? "The named parameter code was used in more than one query."

I am trying to set a parameter for a Query inside a MultiQuery: var multiQuery = SessionHolder.Current.CreateMultiQuery(); foreach (string name in names) { var query = SessionHolder.Current .CreateQuery("select c.Name, c.Surname " + …
Răzvan Flavius Panda
  • 21,730
  • 17
  • 111
  • 169
0
votes
1 answer

PHP MySQL Multi-statement works on my webpage but not on XAMPP

So I use this code to connect to MySQL and execute multiple statements: $connect=@mysql_connect($host,$user,$pass,false,65536) or die("Can't connect"); mysql_select_db($base,$connect); When connected I do: mysql_query("CREATE TABLE IF NOT EXISTS…
Remc4
  • 1,044
  • 2
  • 12
  • 24
0
votes
0 answers

Mysqli Multi Query in OOPs PHP

I don't Understand What is the problem in this code. everything is ok but query didn't execute with multi query. On the other hand every code is working but only this multi query not working // database connection $mysqli = new mysqli(DATABASE_HOST,…
Beast69
  • 1
  • 1
  • 3