user-variables

mysql update statement behaves differently based on whether a user variable exists

I'm reseting a sort column that has duplicate or missing values like so: set @last=''; set @sort=NULL; update conf_profile set sort= if( @last=(@last:=concat(org_id,',',profile_type_id,',',page,',',col)), (@sort:=@sort+1), (@sort:=0) ) order by org_id,profile_type_id,page,col,sort,id; (Go through all th...

Perform UPDATE and setting a user variable in one single query.

Everyone familiar with php's mysql_query command, knows that it doesn't allow us to perform more than one query (separated by the ; delimiter) in one call... My problem is that I wan't to be able to define a user variable in my UPDATE query so that I increment it for each row (kinda like auto increment). It should look like something as...

MySQL select from view with user variables - Unexpected result

I have 2 tables and a view. In product_oper I have some products that I receive (when id_dest is 1) and that I sell (when id_src is 1). The table product_doc contains the date when the operation took place. CREATE TABLE product_doc ( id bigint(20) unsigned NOT NULL AUTO_INCREMENT, doc_date date NOT NULL, doc_no char(16) NOT NULL,...

having trouble with getting rows back from msqli::multi_query

I've got an sql query that contains a number of statements. It: sets a user variable calls a stored procedure calls another stored procedure selects some data I know that the query is correct, because I've tested it in MySQL Workbench, under the same user. The query is this: set @current_post = 535; /* 535 for testing, this will be ...