mysql-5.5

What are the values of columns which are not set in a BEFORE UPDATE trigger?

淺唱寂寞╮ 提交于 2019-12-13 03:59:47
问题 According to MySQL In a before update trigger there are two mysql extensions viz NEW and OLD to refer to the old and new column values of the updating row. Say, my table is : create table foo ( id primary key auto_increment, fname varchar(10), lname varchar(10) ); And I have inserted 1 row: insert into foo (fname,lname) values ("Edam","Chuti"); If I run an update like : update foo set fname="Edam1" where id=1; Then in my before update trigger for this table what will be the values of : NEW

Can you increase max_allowed_packet from the client?

邮差的信 提交于 2019-12-12 19:18:23
问题 I need to execute a SQL dump with very large extended inserts. I'm using the official command-line tool in my computer to connect to a server in the LAN. The execution always dies: ERROR 2006 (HY000): MySQL server has gone away ... and I'm fairly sure that it's due to a tiny max_allowed_packet setting: mysql> SHOW VARIABLES LIKE 'max_allowed_packet'; +--------------------+----------+ | Variable_name | Value | +--------------------+----------+ | max_allowed_packet | 10485760 | +---------------

Get N number of records from child table for each parent record in a MySQL View

落爺英雄遲暮 提交于 2019-12-11 07:12:28
问题 I tried finding answer to this question in SO , but could not find any. Any links will be of great help. I have a parent table and a child table with one to many relationship between the parent and child table. The child table contains around 1 million records and I want to create a view with 1st 10 records in child table for each parent record. Example- Parent_Table - Fields -- ID, Name ID Name ---- ----- 1 A 2 B 3 C Child_Table - Fields -- ID, ParentID, Date, Data ID ParentID Date Data ----

MySQL Escape Character Issue

青春壹個敷衍的年華 提交于 2019-12-11 05:44:29
问题 While I was trying to solve This Question. I created the dummy records in a table create table mytable(data CHAR(30)); INSERT INTO mytable VALUES('d\\one'),('d\\two'),('d\\three'); SELECT * FROM mytable; +---------+ | data | +---------+ | d\one | | d\two | | d\three | +---------+ 3 rows in set (0.00 sec) Now when i am selecting records, I am getting no result, I have tried many combination with like but no luck. Ex : SELECT * FROM mytable WHERE data LIKE "d\\%"; Empty set (0.00 sec) SELECT *

MYSQL - select difference of rows counts in two tables

泪湿孤枕 提交于 2019-12-04 06:20:59
问题 I am trying to compare number of rows of two tables in two databases. The number of rows should be the same : SELECT (SELECT COUNT(*) FROM db1.table1)- (SELECT COUNT(*) FROM db2.table1) AS difference How do i select only if difference<>0? I need to run this for multiple tables and i don't need 0 values. I could load results in C# list and sort it out but i'd like to finish all in query. I've tried using information_schema.TABLES for this but it's not suitable because it returns approximate

gettting an error while defining the event name on mysqlworkbench 5.5

蓝咒 提交于 2019-12-02 08:50:42
I created a stored procedure like the following: -- -------------------------------------------------------------------------------- -- Routine DDL -- Note: comments before and after the routine body will not be stored by the server -- -------------------------------------------------------------------------------- DELIMITER $$ CREATE DEFINER=`MailMe`@`%` PROCEDURE `sp_archivev3`() BEGIN INSERT INTO send.sgev3_archive(a_bi, b_vc, c_int, d_int, e_vc, f_vc, g_vc, h_vc, i_dt, j_vc, k_vc, l_vc, m_dt, n_vch, o_bit) SELECT a_bi, b_vc, c_int, d_int, e_vc, f_vc, g_vc, h_vc, i_dt, j_vc, k_vc, l_vc, m

Slow query after upgrade mysql from 5.5 to 5.6

混江龙づ霸主 提交于 2019-12-01 14:15:29
We're upgrading mysql from 5.5 to 5.6 and some queries are deadly slow now. Queries that took 0.005 seconds before are now taking 49 seconds. Queries on 5.6 are skipping the indexes, it seems: +----+-------------+-------+-------+----------------------------------------------------+---------+---------+------+--------+-------------+ | id | select_type | table | type | possible_keys | key | key_len | ref | rows | Extra | +----+-------------+-------+-------+----------------------------------------------------+---------+---------+------+--------+-------------+ | 1 | SIMPLE | pens | index | index

Slow query after upgrade mysql from 5.5 to 5.6

时光怂恿深爱的人放手 提交于 2019-12-01 11:30:57
问题 We're upgrading mysql from 5.5 to 5.6 and some queries are deadly slow now. Queries that took 0.005 seconds before are now taking 49 seconds. Queries on 5.6 are skipping the indexes, it seems: +----+-------------+-------+-------+----------------------------------------------------+---------+---------+------+--------+-------------+ | id | select_type | table | type | possible_keys | key | key_len | ref | rows | Extra | +----+-------------+-------+-------+---------------------------------------

subquery returns more than 1 row

旧街凉风 提交于 2019-11-30 19:20:53
select disease_name from disease where disease_id= (select disease_id from disease_symptom where disease.disease_id=disease_symptom.disease_id AND symptom_id= (select symptom_id from symptom where symptom.symptom_id=disease_symptom.symptom_id AND symptom_name='fever' OR symptom_name='head ache')) Gives an error that subquery returns more than one row. what is the cause? Your two outer queries are structured to expect a single result from the their subqueries. But the way you have things structured, your subqueries might return more than one result. If you actually want more than one result,

subquery returns more than 1 row

回眸只為那壹抹淺笑 提交于 2019-11-30 03:00:18
问题 This question was migrated from Database Administrators Stack Exchange because it can be answered on Stack Overflow. Migrated 6 years ago . select disease_name from disease where disease_id= (select disease_id from disease_symptom where disease.disease_id=disease_symptom.disease_id AND symptom_id= (select symptom_id from symptom where symptom.symptom_id=disease_symptom.symptom_id AND symptom_name='fever' OR symptom_name='head ache')) Gives an error that subquery returns more than one row.