Questions tagged [mysql5]
The MySQL™ software delivers a very fast, multi-threaded, multi-user, and robust SQL (Structured Query Language) database server.
223
questions
-2
votes
1
answer
39
views
MySQL Leaderboard Table
I'm trying to figure out how to Select a specific number of rows from a MySQL table based on WHERE clause. I have a table with 10 dummy users, I want to get 2 previous and 2 next users of specific ...
0
votes
0
answers
9
views
the cursor of mysql5 must be fixed sql sentence,How can I realize cursor of string sql sentence?
Here is my aim.
I want to make a procedure which can push a param of sql string and make the sql string into cursor
such as
DELIMITER $$
DROP PROCEDURE IF EXISTS sp_test$$
CREATE PROCEDURE sp_test(IN ...
0
votes
0
answers
75
views
Creating aggregated column in SQL with values depending on previous row - MySQL 5
I would like to get some help on the following query:
I have the following data frame I created with python pandas:
data = pd.DataFrame({'user_id':[1,1,1,2,2],'event':[1,0,1,1,0]})
The output is:
...
0
votes
3
answers
116
views
Sort records based on string
Please consider the table below
Id F1 F2
---------------------------
1 Nima a
2 Eli a
3 Arian a
4 Ava ...
0
votes
0
answers
46
views
rowcount and db size not same after migration from mysql 5 to mysql 8
I upgraded my database from mysql 5 to mysql 8.
After backup from mysql 5 and restore to mysql 8, the db size and the rowcount for table isn't same.
Is there any explanation why because the log show ...
0
votes
1
answer
341
views
MySQL 5.7 recursive query on hierarchy data with unknown levels
I am developing a hierarchy data structure where I want to perform a recursion to get the desired output
id role_id reporting_to
------+-------------+-----------------
1 100 ...
0
votes
1
answer
911
views
docker-compose run mysql: ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)
I'm totally roasted after working 14 hours straight, and even after crawling the whole internet I'm unable to resolve this problem.
The scene is imaginable simple:
I have a docker-compose.yml with ...
0
votes
2
answers
110
views
MYSQL View Query Performance Issue
I have 5 SQL tables
store
staff
departments
sold_items
staff_rating
I created a view that JOINs this four of the tables together. The last table (staff_rating),I want to get the rating column at a ...
0
votes
2
answers
51
views
MYSQL 5: Returning expression if statement is false, similar to NULLIF
I have a long complicated expression that refers to multiple tables. The expression returns a string, but i want to return a different string if the returned string was empty "".
With the IF ...
0
votes
1
answer
130
views
Getting MySQL error creating handler in an event
I'm trying to create an Event in MySQL 5.6 and I'm getting an error whenever I try to DECLARE something, like a parameter or handler:
SQL Error [1064] [42000]: You have an error in your SQL syntax; ...
-1
votes
2
answers
68
views
how to simplify this sql
I have a problem in my sql expression, I want to put different columns in a main select,these different columns has the same where clause.
Here is my sql example:
SELECT t.*,
(SELECT monitor_value
...
0
votes
0
answers
54
views
MySQL median with 2 group by
I have the following table
Date | year | quarter | val1 | val2 |
-----------|-------------|----------|---------|-------------|
2020-01-01 | 2020 | Q1 | 10 | ...
1
vote
2
answers
1k
views
why mysql does not reclaim free space in ibd file?
I am using mysql5, and I want to shrink some 'deleted' spaces in ibd file. I already search for 'optimize table' option, but I cannot use it now, because it is a very critical table. It uses 19G in ...
0
votes
2
answers
55
views
Optimize UPDATE JOIN query in MYSQL
I am running the following SQL query:
UPDATE A
join B
on A.b_id = B.id
SET B.col1 = 'val1'
, B.col2 = ''
, B.col3 = 1
where a.col4 = 'val4'
and b.col5 = 1234
and b....
0
votes
1
answer
321
views
Fetching rows with updated at timestamp older than 1 day in mysql
I have a table with schema as follows:
mysql> desc a;
+---------------+------------------+------+-----+---------+----------------+
| Field | Type | Null | Key | Default | ...
0
votes
1
answer
192
views
Checking if contents of two table are identical in MySQL
I have views in two databases V1 and V2 with same set of columns col1, col2.
Now I would like to know if they contains identical rows. In this context I have gone through this post: SQL compare data ...
0
votes
1
answer
223
views
Using Python 3/Django, how do I export MySql table data as a YAML file?
I'm using Python 3.7, Django 2.0 with MySql 5.7. I have an InnoDB table
mysql> show create table address_country;
+-----------------+---------------------------------------------------------------...
4
votes
1
answer
1k
views
How do you configure Django 3 to work with MySql 5?
I'm using Mac 10.13.6 and MySql 5.5 (can't upgrade at this time). I have just created a skeleton Django (v 3.0.2)/Python 3.7 app and configured my database setting like so
DATABASES = {
'default'...
0
votes
3
answers
267
views
select count(*) query is too slow. I'm guess it is not work by indexing
I would like to ask for comment because I did a better search.
My server environment is below.
CentOS release 5.1
Linux 2.6,18
CPU: Intel (R) Xeon (R) CPU E3-1230 v3 @ 3.30GHz 8core
M / M: 8 GB
...
0
votes
0
answers
17
views
Finding rows which have other characters in addition to alphanumerical value in a column. MySQL
Using MySQL 5, I have around 100000 rows in a table.
In addition to the alphanumerical characters some of the rows have other characters like special characters for a column, let's say column1.
I ...
0
votes
2
answers
98
views
Why local variable doesn't save value?
I'm writing query in mysql5.7 to emulate dense_rank(). I have problem with scope of variable.
I've tried using variable in diffrent ways, but always Place in rank is wrong counted. It seems that ...
-2
votes
3
answers
132
views
MySQL ORDER BY field with a toggle
I have a mysql result that looks like this:
| compare | field1 | field2 | much more |
-----------------------------------------
| new | x1 | y | ... |
| old | x1 | y | ...
0
votes
2
answers
137
views
MySQL self-referencing JOIN
I have two tables:
Customers (
int(11) Id,
varchar(255) Name,
int(11) Referred_ID -- Referred_ID being reference to an Id field
-- (no key on that field) and
)...
0
votes
1
answer
41
views
MySQL - Top 5 rank best seller plans or courses
I sell subscriptions of my online course, as well as the courses in retail.
I would bring the "top 5" of best selling plans / courses. For this, I have a table called "subscriptionPlan", which stores ...
1
vote
1
answer
471
views
Same query returns different values on repeated execution
Database in use: 5.6 (I can't use LAG function which is from mysql 8)
I have the following table structure in mysql
book_id | Version | Rating | Price
varchar(25) | Decimal(10,2)| int | ...
0
votes
1
answer
62
views
Working procedure of RAND() in MySQL?
i'm trying to select 5 rows randomly from my table using RAND() in mysql, and i've set the LIMIT as 5 but why sometimes it will return less than 5 rows?
Here is my Query:
SELECT id from MAIL where ...
0
votes
1
answer
367
views
powerdesigner how to generate sql using `backquote`
Sybase PowerDesigner Version 16.0.0.3514
Current DBMS mysql 5.0
Generate SQL
In fact, I want to add backquote around the field name, like this
How to configure it?
1
vote
1
answer
27
views
Python read data from mysql errors
I want read a column from mysql ,multiply a factor and write into mysql
cursor = db.cursor()
query = ('SELECT GDP FROM selectedairport')
cursor.execute(query)
gdp_list = []
for GDP in cursor:
...
0
votes
1
answer
552
views
mysql error syntax in python
sql = """
DROP PROCEDURE
IF EXISTS schema_change;
delimiter ';;'
CREATE PROCEDURE schema_change() BEGIN
if exists (select * from information_schema.columns where table_schema =
schema() and ...
0
votes
2
answers
61
views
using AS field in WHERE clause
In the following example :
SELECT op.product_id, op.name, IF(op.sku <> '', op.sku, op.model) AS op_sku,
SUM(op.quantity) AS quantity
FROM order_product op GROUP BY op_sku ORDER BY op_sku ASC ...
2
votes
0
answers
78
views
MySQL process List
We have a dedicated master server with 32GB of memory and 20 CPU linked to two other slaves , we are in constant need of restarting the mysql process due to memory issue .
When I run the SHOW FULL ...
0
votes
2
answers
842
views
What is the Groovy syntax for Liquibase preconditions?
Summary
I have to add a column on a table if it does not exist.
Column Name: myColumn
Table Name: myTable
Using the Groovy language and Liquibase, I want to check for column existence and create ...
1
vote
1
answer
130
views
MySQL ISAM search optimization
I have a table with 1,019,502 records and a specific query that is taking 1.6 seconds to run. I would like to reduce the run time if possible.
The table is INNODB on MySQL 5.7 (on Ubuntu):
mysql> ...
0
votes
2
answers
51
views
Create one big table from more same tables
Long time ago I created application which contains database with table for each user and every table has only 1 row. So I have tables like user1, user2, ..., user2800. Now I know it was a terrible ...
1
vote
2
answers
373
views
mysql stuck in inner join query
i have a mysql db with around 200 tables & each tables have around 40,000 entries.
i m trying inner join, but on xamp environment, it takes around 4hrs... as well as on cloud it simply gives error ...
2
votes
0
answers
216
views
Moving MySQL data to another drive
I want to move my data in C:\ProgramData\MySQL\MySQL Server 5.5\data to E:\Mysql5Data
Stopped MySQL5 Service
Changed "datadir" value in my.ini file to E:/Mysql5Data
Started MySQL5 Service
I got ...
0
votes
1
answer
771
views
Mysql Not Working After El Capitan Upgrade
I recently upgraded my Mac Pro to a Mac Mini and used the migration assistant to transfer all my files and applications across to the Mac Mini.
I also re-installed macports and configured apache etc. ...
0
votes
1
answer
59
views
Is this MongoDB use case?
I have a dating website in which i send daily alerts and log alerts in ALERTS_LOG.
CREATE TABLE `ALERTS_LOG` (
`RECEIVERID` mediumint(11) unsigned NOT NULL DEFAULT '0',
`MATCHID` mediumint(11) ...
0
votes
1
answer
2k
views
#1293 - Incorrect table definition; there can be only one TIMESTAMP column with CURRENT_TIMESTAMP in DEFAULT or ON UPDATE clause
I have a Magento2 website and wanted to deploy on a server. I got the above mentioned error when I tried to import DB copy of a local to the live mySQL server. I found the reason that on local system ...
1
vote
0
answers
48
views
Why doesn't this work to connect my database?
What did I do wrong with this code ?
$query = "SELECT name, emailadres FROM people";
//query is aangemaakt
$sql = mysqli_query($mysqli, $query) or die (mysqli_error());
//query is uitgevoerd
and ...
0
votes
0
answers
56
views
Getting blank page when article trespasses certain amount of alpha numeric characters
I've been writing an article for almost 1 month, it's a super list that has over 180+ itens, including imagens as previews. Problem is that when I reached some point, the article's page got blank. It'...
0
votes
0
answers
64
views
Mysql cache is my headache
This is my status of query cache
SHOW STATUS LIKE 'Qcache%';
+-------------------------+------------+
| Variable_name | Value |
+-------------------------+------------+
| ...
0
votes
2
answers
53
views
Why does ordering rows lessen the row count in an explain?
I have a table with some two or three million rows…
mysql> select count(*) from tbl;
+----------+
| count(*) |
+----------+
| 2615889 |
+----------+
1 row in set (1.23 sec)
mysql> show ...
0
votes
1
answer
105
views
MySQL Keeps Forgetting Root Password Used to Install
I'm using the MySQL Installer on Windows 8.1. I go through the installation steps for MySQL Server, including setting my password. However, when I go back to reconfigure my server through the ...
1
vote
1
answer
3k
views
MySQL NEW keyword
I have what seems like a basic question, but I have been unable to find the answer. Does the NEW keyword in MySQL refer to what the row will look like after the given action is performed or does it ...
1
vote
1
answer
1k
views
Query End concept
My table MYTABLE contains 14 million record data
CREATE MYTABLE `MYTABLE` (
`COLUM1` int(10) unsigned NOT NULL DEFAULT '0',
`COLUM2` int(10) unsigned NOT NULL DEFAULT '0',
`COLUM4` datetime NOT NULL ...
0
votes
0
answers
55
views
database table is getting emptied on phpmyadmin automatically,randomly
My database table on phpmyadmin is being automatically emptied periodically. Sometimes all the data is getting deleted after 2-3 days, sometimes it takes weeks to get emptied. I didn't find any ...
0
votes
1
answer
557
views
INNODB query end
My table TABLE IS INNODB
query end | REPLACE INTO TABLE (COLUM1,COLUM2,DATE) VALUES (14411,132,'2015-07-01 12:12:33')
Its taking 2 seconds ?
Whats query end ?
0
votes
0
answers
856
views
How to connect PHP Nightrain with MySQL 5
I have developed Web Portal using PHP and next step is to convert web portal into Desktop Application.
I'm using PHP Nightrain for converting Web Portable to Desktop Application.
But problem is, I ...
0
votes
1
answer
31
views
Too much time on optimal path
Below query has taken just 0.04 second
SELECT A.*
FROM `TABLE1`
JOIN TABLE2 ON ( TABLE1.ID = TABLE2.ID )
WHERE `COL1` ='1'
While next query has taken 4 seconds
SELECT A.* FROM `TABLE1`
JOIN ...