mysql-workbench

How to call a stored procedure within another stored procedure (PHP and mysqli)

旧时模样 提交于 2019-12-25 11:46:11
问题 I am struggling to call a stored procedure within another stored procedure. Like it is now the stored procedure never return the SELECT statement back as a result to the mysqli call in PHP (but it works fine in MySQL workbench). DELIMITER $$ CREATE DEFINER=`root`@`localhost` PROCEDURE `new_bid`(IN bid_in decimal(6,2), IN ticker_in varchar(5), IN share_amount_in BIGINT) BEGIN DECLARE company_id_var INT; DECLARE highest_bid BIT; DECLARE generated_bid_id BIGINT; SET company_id_var = (SELECT ID

How to call a stored procedure within another stored procedure (PHP and mysqli)

江枫思渺然 提交于 2019-12-25 11:45:10
问题 I am struggling to call a stored procedure within another stored procedure. Like it is now the stored procedure never return the SELECT statement back as a result to the mysqli call in PHP (but it works fine in MySQL workbench). DELIMITER $$ CREATE DEFINER=`root`@`localhost` PROCEDURE `new_bid`(IN bid_in decimal(6,2), IN ticker_in varchar(5), IN share_amount_in BIGINT) BEGIN DECLARE company_id_var INT; DECLARE highest_bid BIT; DECLARE generated_bid_id BIGINT; SET company_id_var = (SELECT ID

Join Tables MySQL

≯℡__Kan透↙ 提交于 2019-12-25 11:26:32
问题 I have multiple tables and made 2 sub-selects (UserRecord,CustomerRecord) that i would like to merge into 1 table UserRecord ======================== | RecordID | UserName | ======================== | 1 | Sara | | 1 | Tom | | 2 | Sara | | 2 | Kurt | | 3 | Fre | ======================== Table: CustomerRecord ============================ | RecordID | CustomerName | ============================ | 1 | Jef | | 2 | Alex | | 2 | Peter | ============================ Table: This should be the result =

Grant select privilege to rows with condition

梦想的初衷 提交于 2019-12-25 07:15:44
问题 how to grant a read privilege to all information included in a view DRVADM except the rows where a date of birth is not empty to a user? 回答1: Consider the following: drop table if exists variousRights; create table variousRights ( -- whitelist table of various privileges id int auto_increment primary key, rightType varchar(100) not null, username varchar(100) not null ); -- sample data below. For this exercise, all we care about is 'seeNullBirthDateRows' -- but other data is inserted to

MySQL query slows down when another query is concurently sent

放肆的年华 提交于 2019-12-25 07:04:24
问题 I am using an InnoDB table that currently has 16m of records. When I run the following query by using MySQL Workbench, it returns in about 14 seconds: SELECT countryCode AS label, SUM(count) AS value FROM AnalyticsPieCharts GROUP BY label ORDER BY value DESC; When I run the same query from a different computer, while the first one is running, both return in about 23-24 seconds. I haven't created any indexes (except of the primary key) or put transaction rules. I am using Amazon RDS. Do you

Create View in a Trigger

孤街浪徒 提交于 2019-12-25 03:56:16
问题 I have to use a view (not already created, because it's needed within that UPDATE TRIGGER) in an UPDATE inside an UPDATE TRIGGER. So this is my code: CREATE TRIGGER lunghezza_sentiero_datoderivato_UPDATE2 AFTER UPDATE ON TAPPA FOR EACH ROW BEGIN CREATE VIEW tempoOLD_NULL(IDsentiero, tempo) AS SELECT IDsentiero, tempo FROM SENTIERO WHERE tempo IS NULL and SENTIERO.IDsentiero IN (SELECT DISTINCT IDsentiero FROM SENTIERO__HA__TAPPA AS sht WHERE NEW.IDtappa=sht.IDtappa); CREATE VIEW lunghezzaOLD

Get inserted id from mysql insert procedure

北慕城南 提交于 2019-12-25 03:05:28
问题 I create a procedure for insert statement with some input parameters. But i want to get the inserted id or inserted row from the same procedure.I created using oracle, that is working fine. But i don't know in mysql. And spend more time to get this.i can't. 回答1: MySQL solution: After running the insert statement, execute select last_insert_id() into lastId; Change your SP to include an OUT parameter as OUT lastId bigint or simply run select last_insert_id(); to return a result set by the SP;

Mysql Insert data into multiple table

假如想象 提交于 2019-12-25 02:52:09
问题 I am experiencing a problem in MYSQL insert. Could any experts will answer this. Below is my question. Photo table : pid - PK, photo_src, photo_size, created , Photo_link table : - for linking more than one image in Blog table . id , pid -FK Blog Table : bid - PK, content, created, id - will have photo_link table id . Photo : | pid | photo_src | photo_size | created | +-----+--------------+------------+---------------------+ | 1 | /photo/1.jpg | 400 | 2014-05-27 11:58:45 | | 2 | /photo/2.jpg

COALESCE Extrage results on dates and strings

自闭症网瘾萝莉.ら 提交于 2019-12-25 02:43:29
问题 First of all, I want to clarify that I have already read this question. The problem described there is quite similar to my problem but related with a bug, which has been already solved. I have been getting strange results after querying a MySQL Server (Ver 14.14 running on Linux) through MySQL WorkBench 5.2.47 C running on Windows. The problem is that selections on COALESCE over a list of date and string fields return BLOBS instead dates. For example SET @dat='20130812'; SELECT COALESCE(dateA

MySQL alters table name case

二次信任 提交于 2019-12-25 02:21:07
问题 When I use MySQL Workbench to Forward engineer my model to a work book, it creates a script file with the names of the tables in quotes. The table names are all in mixed case, but when the script runs, only the very first table is created with mixed case and the rest are created only in lower case. The first two tables out of 20+ are shown before: SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0; SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0; SET @OLD_SQL_MODE=