MySQL : Open-Source, Relational Database Management System

learn more… | top users | synonyms

4
votes
6answers
1k views

How to find the nth highest salary in SQL?

I have found a query to find the nth highest salary from Employee table , but i don't understand the logic of (N-1)? EmpID Salary 1 90000 2 80000 3 54000 4 ...
0
votes
1answer
18 views

Does having no brackets at “WHERE” produce same results as having brackets? [closed]

Does having no brackets at "WHERE" produce same results as having brackets? I have same result, just wanted to confirm, because from my memory it always best to use rounded brackets. SELECT ...
0
votes
0answers
17 views

Memory consumption of production MySQL

The MySQL database on one of my production servers consumes a lot of memory. The problem is that I cannot trace what causes that kind of high memory usage. Following values illustrate the problem. ...
0
votes
1answer
35 views

How to determine if an Index is uselss in Percona MySQL?

Using Percona Server 5.5 I've a table which stores user activty (lets call it user_activity). It was created quite a few years ago when I had only a little bit of knowledge about database ...
3
votes
3answers
56 views

Select Column value based on two values in another column

I am using the below table: 1 0051ML66220600132482 06:00:00 06:00:00 1538 100 0 1 2 0051ML66220600132482 06:00:00 06:00:00 1540 200 0 0 3 ...
3
votes
2answers
62 views

Mysql Index for concat select

For Below Query SELECT MAX(CONCAT(date, ' ', last_entry)) AS LAST_LOG FROM entry_log WHERE TRIM(LEADING 0 FROM card_no)='2948' I've index on date card_no date,last_entry ...
0
votes
1answer
26 views

Sync Data Without Replication

I have a database server I am using an old dump from to restore due to the need of older records that must be brought back. I also need to sync to this database the new entries from the current ...
0
votes
1answer
31 views

Query databases that have MYISAM tables that do not have only fulltext index tables

I am trying to query from the information_schema where the database (table_schema) has MYISAM tables but does not have only fulltext index tables. The statistics tables is very poorly designed for ...
0
votes
0answers
23 views

Insanely slow replication after MHA promotion

I have a replication setup with 1 master and 3 slaves. I promoted the current master to one of the slaves using MHA. That went seemingly flawless, not errors reported, everything marked ok. Spot ...
1
vote
2answers
91 views

Normalization of library book table with multiple authors

I have a database structure with two tables: The first one is called Author, has two columns (AuthID, AuthName) and its Primary Key is (PK_AuthID). The second one is called Book and has three ...
0
votes
1answer
40 views

set session wait_timeout inside of phpmyadmin for export/import

I need to increase wait_timeout variable in mysql only when access mysql from phpmyadmin. I don't want to edit my.cnf file or set it globaly in mysql server. I've read documentation, but haven't ...
1
vote
2answers
138 views

How to join tables when one of them doesn't have any relationship with the others

First of all, I know what I am about to show you is a completely DB mess but I just got it like this. Tables : Authors manufacturers_id manufacturers_name 1 Name1 2 ...
0
votes
2answers
30 views

How to create function using another functions mysql

I want to create a function in MySQL using another function but I am getting an error "Explicit or implicit commit is not allowed in stored function or trigger". This is my code: DELIMITER $$ ...
2
votes
2answers
433 views

If exists then update else insert

I am trying to create a STORED PROCEDURE that will be used to UPDATE a table called machine. This table has three columns (machine_id, machine_name and reg_id). In aforementioned table,reg_id (INT) ...
1
vote
2answers
28 views

professional services (consultants) resource allocation system

I am developing a resource allocation system using PHP and mysql. I have consultants and projects and I need to allocate the consultants on to various projects for various periods of time on various ...
2
votes
2answers
52 views

What are some known hazards with cyclical replication between two MySQL master servers?

If I were to set up cyclical replication between a MySQL 5.6 master server and a MySQL 5.1 master server, what are some things that could potentially go wrong? Also, the 5.6 MySQL does not have GTID ...
1
vote
1answer
58 views

Rich text: VARCHAR, TEXT or BLOB in MySQL

Question: In my web application (php/MySQL) I will be saving rich text. This may be anything from a couple words to several pages length essay. I’m sure I could get away with using VARCHAR, TEXT or ...
1
vote
0answers
33 views

Using SESSION sql_mode = 'NO_BACKSLASH_ESCAPES' before running query to remove backslashes in database

See this post: How do I remove backslashes from records in MySQL I have similar issues in that code that was developed before me did not use strip slashes with magic_quotes_gpc on before inserting ...
1
vote
0answers
21 views

A design pattern for category features [closed]

I work for a system which has these tables: products , categories , features User wants to add some feature like color dynamically. Which of this following ways are true? First one: Product ...
1
vote
1answer
192 views

How to remove leading zero from date [closed]

I have a query in which i have used the following date_add(DATE_FORMAT(ss.week_startdate,'%y-%m-%d'),INTERVAL (tt.day_id- 1 )DAY) as date Datatype of the field is datetime and the result date is ...
0
votes
0answers
14 views

how to install lib_mysqludf_xql?

Can any one provide me a steps how to install lib_mysqludf_xql? OS version is REHL 6.5(64 bit) and MySQL version is 5.5.27 we installed MySQL with the source code.
3
votes
0answers
14 views

How does mydumper's ''--use-savepoints" option reduce metadata locking

MyDumper 0.6.1 add a new option --use-savepoints. From the manual, it means: Use savepoints to reduce metadata locking issues, needs SUPER privilege I don't understand. How does it "reduce ...
1
vote
1answer
23 views

MySQL GTID replication: is it possible to make DDL changes to a slave and then catch it up to a master?

Here's what I would like to do: 1. hang a slave off my production master. 2. stop replication 3. adjust some data types and create some indexes on the slave (no data mods) 4. restart replication 5. ...
0
votes
1answer
26 views

MySQL on Ubuntu consuming almost all RAM

I've been having an issue with MySQL crashing randomly, apparently as a result of not having enough available memory (as discussed here: ...
1
vote
1answer
41 views

Insert/ Update Scalability (more records, continually longer lookups — solution?)

posted this before but never received a clear answer. I'm working on an ETL project and am basically feeding JSON records of "tickets" into a MySQL database. (actually come to think of it, may be ...
2
votes
3answers
65 views

Query 'optimizing' state is taking too long

I have a MySQL 5.6 on Amazon RDS that I'm using for testing some data archiving scripts. I'm removing oldest data based on a "updated_date" column and index. Curiously, after removing a few million ...
2
votes
2answers
65 views

Does MySQL support querying for the current running transaction id

PostgreSQL supports retrieving the current running transaction id using a query like this: select txid_current(); Does MySQL have any such equivalent?
1
vote
2answers
118 views

grant select on all databases except one mysql

I have user called test_user created under MySQL 5.5.17 under MS Windows 2008R2, I want to grant this user select privileges on all databases except MySQL database, note I have around 200 database ...
0
votes
0answers
40 views

SQL Server to MySQL data transfer using Talend Open Studio - recent performance drop

I have a problem with data transfer speed from SQL Server to MySQL server using Talend Open Studio. Normally my job has been able to transfer about 5000 rows/sec-7000 rows/sec. But lately the job ...
0
votes
3answers
53 views

Schema Design with “Seasonal” Data

I am developing a SaaS web application for School Management. What I need help is this: The whole application is purposed for the current year that the School is in. However, some data and ...
1
vote
1answer
26 views

Duplicate delete query in binary log of MySql Master

We are facing strange problem, while replication data from master to slave. Same data is being deleted twice in log(How ever only one row is deleted and one time),due to which we are getting error ...
0
votes
0answers
11 views

Mysql copying from varchar column to a decimal coulmn [migrated]

I have a column in MySQL table (First table) has varchar data type, I used JDBC driver to insert data of numerical data type on the mentioned column . Why I choose varchar data type of this type? ...
1
vote
1answer
32 views

Write-lock a whole table during transaction

I need to perform a delicate operation to my table in which I will solely insert, delete and select upon all of my rows and no God may interfere with the table during this operation: the table will be ...
1
vote
1answer
32 views

Search functionality using joins

I have three tables as mentioned below. I need to implement basic search functionality where the user will search for a keyword which could either match 'title' (from Proposal table) or 'msNumber' or ...
2
votes
2answers
51 views

Mysql slow query log always include “# Time:”

I am trying to parse the mysql slow log with logstash so it's important that the format is consistent. I have noticed that if statements execute at the same time, the line # Time: yymmdd is only ...
2
votes
0answers
23 views

creating deadlock for distributed database in mysql-(Testing purpose)

I need to create a deadlock for distributed database in MySQL for testing purpose with a simple sql query(without front end), can anyone good with MySQL query help me out in this with sample query. ...
0
votes
1answer
32 views

Use Create Trigger to create New table using calculated values from common groupid column values

I have a TABLE_A in Database1 the contains rows with a common group id. I am wanting to use the CREATE TRIGGER function to generate a new TABLE_B in the same Database1 that contains calculated values ...
2
votes
1answer
22 views

Is there an easy way to update a mysqldump file from version 9.11 to 10.11? [closed]

We have a client that has had their servers for soo long, they were still running MySQL 4.0.24. Now that they are refreshing their servers, we took a mysqldump of their current database to put into ...
0
votes
0answers
20 views

Database Importing Collation

Migrating from DB2 found this error message: Error message: Incorrect string value: '\xF2\xAC\x9F\xB0or...' for column 'column_name' This is when trying to import an XML to MySQL. I should have a ...
5
votes
1answer
67 views

MySQL overhead of calling a Stored Procedure

Within Java, we access MySQL (v5.5.40) via JDBC -- a prepare statement, setting parameters then calling the stored procedure. It appears that every execute() has the overhead of 4 meta-calls (per ...
0
votes
0answers
6 views

MySQL log shows excessive meta queries on SP calls [duplicate]

We access MySQL via JDBC -- a prepare statement, parameters binding then invoking the actual stored procedure. It appears that every execute() has an associated "overhead" of 4 meta-calls (per MySQL ...
1
vote
1answer
41 views

Is there a performance hit for querying two different databases?

I have two tables, A and B, which are located in different databases on the same MySQL server. I would like to create a derived table C from tables A and B, as an inner join between the two tables. ...
0
votes
2answers
14 views

Structure database(s) dealing with different time points

I have few data sets that give a score for a specific account at a specific point in time. So, account A might have a different score each quarter going back 5 years so. There aren't a ton of data ...
6
votes
3answers
121 views

Convert date in date list condition to list of date ranges

I want to look for all the records that occur on specific dates. SELECT * FROM table1 WHERE date(column) in ($date1, $date2, ...); However, as many of you, know this kind of comparison doesn't get ...
0
votes
1answer
26 views

mysql prevent update other salve-master db while any record update in slave db

I have master and 3 slave (slave1,salve2,slave3) db in same host. So when I update any record in slave1 db its affected on all other master and salves db. My Question is: How to prevent update all ...
1
vote
0answers
13 views

MySQL performance of trigger when many rows are affected

I have a question on MySQL triggers which I hope someone might be able to help with. As part of our platform, we have a table (accounting), which grows rapidly. We also have an archived version of ...
1
vote
0answers
64 views

Getting count of visits for multiple different outlets

I'm trying to get the distinct count of id that visited different outlets. I have more than 50 outlets so I don't think I can use the IN operator. CREATE TABLE transact ( year int NOT NULL, card_id ...
0
votes
1answer
42 views

How to enable queries logs in MariaDB

I'm running mysql Ver 15.1 Distrib 5.5.42-MariaDB, for Linux (x86_64) using readline 5.1 in CentOS 6.6 server. I'm trying to get queries logging info and I'm doing by enabling log support at ...
0
votes
2answers
30 views

MariaDB/InnoDB: What to do on “Locks in Status-Log but no locked table found”

We migrated lately from MySQL to MariaDB. SELECT VERSION() 10.0.13-MariaDB-log When executing this: SHOW ENGINE INNODB STATUS I get (shortened): ... ---TRANSACTION 279257007, ACTIVE 23981 ...
0
votes
1answer
26 views

How to join tables without identifiers?

For school I have to do this: Query what salary scale an employee belongs to displaying these collumns: s_schaal.schaal, werknemer.name, werknemer.salaris. But there are no identifiers between the ...