I was testing my software which is in cpanel. But I am getting this whenever I run a single page. Other pages are working properly. the database table is having 12000+ data.is it because it takes much time to load
The same works perfect in localhost. Just now I uploaded it to cpanel.
Query
SELECT * FROM `service_sales_invoice` LEFT JOIN `service_sales_invoice_data` ON `service_sales_invoice`.`invoice_number` = `service_sales_invoice_data`.`invoice_number` WHERE `date` >= '2019-05-01' AND `date` <= '2019-06-20' ORDER BY `date`
Expected result is it works properly. But not.
Related
I have an issue running a query on MySql using a Goapplication.
My local version works fine using mysql 8.0.21 but the same query on my staging version 5.7.12 on aurora fails
SELECT COUNT(*) AS cnt
FROM (
SELECT ? AS item_id, ? AS ar
)
AS A
JOIN item ON A.item_id = item.id
AND A.ar + item.existing_qty > item.qty;
Running this code in data grip with replacements works fine on both local and staging
Running this code but replacing the question marks with ints works fine
The error I get is:
Error 1054: Unknown column 'A.ar' in 'field list
I am thinking there is some driver / version issue
Does it work if you phrase the query like this?
select count(*)
from item
where item = ? and existing_qty + ? < qty
This is the same logic as your original query, and the parameters are passed in the same order.
I have an SQL query with 2 subqueries. whenever I run it on MySQL Workbench on macOS, it gives "Error Code: 2013. Lost connection to MySQL server during query". However, when it runs on Workbench on Windows, it runs normally without any errors.
I tried to increase the connection timeout, but still no success!
Any clue on how to solve this issue?
I appreciate your support and cooperation.
here is a query that gives an error:
with t1 as(
SELECT s.name rep_name, r.name region_name, sum(o.total_amt_usd) as total_amt
FROM sales_reps s
JOIN accounts a
ON a.sales_rep_id = s.id
JOIN orders o
ON o.account_id = a.id
JOIN region r
ON r.id = s.region_id
group by 1,2),
t2 as(
select region_name, max(total_amt) as total_amt
from t1
group by 1)
select t1.rep_name, t1.region_name, t1.total_amt
from t1
join t2
ON t1.region_name = t2.region_name AND t1.total_amt = t2.total_amt;
Your query is taking too long to return data so the connection gets dropped. There are 2 ways to fix this issue.
(i) Optimize query
(ii) Increase MySQL timeout
Explaining 2nd way:
1. In the application menu, select Edit > Preferences > SQL Editor.
2. Look for the MySQL Session section and increase the DBMS connection read time out value.
3. Save the settings, quite MySQL Workbench and reopen the connection.
Finally, I uninstalled the workbench and installed it again and now it is working properly. Thanks for who tried to answer my questions.
I'm running a cron daily, and keep records saved in a table. Wrote a query to see the daily progress of the users, but facing an issue.
I have local and production environments with separate data bases.
SELECT *, LAG(value) OVER(PARTITION BY node_id ORDER BY created_at) old_value
FROM ledger WHERE ledger_type_id = 1
This is the part of the query that is failing. I think the db driver has something to do it. The query was working on the prod data base, from my SQL client, but I just noticed that it is running MySQL 8, and the prod db is 10.3.16-MariaDB.
Tried the same query on my local data base - MySQL 5.7, and got this error:
[2019-08-06 16:12:47] [42000][1064] You have an error in your SQL syntax;
check the manual that corresponds to your MySQL server version for the right syntax
to use near '(PARTITION BY node_id ORDER BY created_at) AS old_value
After this I did 2 more tests:
Ran the query on the prod server it self, via phpmyadmin, and the server complete died, for a few minutes.
Ran the query from my code on the prod environment (laravel 5.8):
DB::select(DB::raw('
SELECT *, LAG(value) OVER(
PARTITION BY node_id ORDER BY created_at
) old_value
FROM ledger WHERE ledger_type_id = 1
'))
and got this in my laravel log:
production.ERROR: SQLSTATE[42000]: Syntax error or access violation:
1140 Mixing of GROUP columns (MIN(),MAX(),COUNT(),...) with no GROUP columns is
illegal if there is no GROUP BY clause
Am I doing something incorrect?
I am using the following SQL query
select links.id, links.title, links.url, links.user_id, links.created_at, sum(vote) as votes, (sum(vote)) / POWER(time_to_sec(TIMEDIFF(now(),links.created_at))/3600, 1.8) as rank from links inner join votes on links.id = votes.link_id where links.language_id = 2 group by links.id order by rank, links.id DESC LIMIT 10
which works fine locally but on my production server I get an error:
#1690 - DOUBLE value is out of range in 'pow((time_to_sec(timediff(now(),`zavoon-news`.`links`.`created_at`)) / 3600),1.8)'
my development and production environment both use the same version of MySQL: Ver 14.14 Distrib 5.7.20
My understanding is the that this part:
time_to_sec(timediff(now(),`zavoon-news`.`links`.`created_at`))
is getting out of range but I have no idea why. I looked in Google but I couldn't figure it out.
Here is an sqlfiddle: http://sqlfiddle.com/#!9/f42838/1
Help much appreciated : )
This gives me strange error.
> Customer.where(:my_text_field => "05007062").first
> Customer Load (0.9ms) SELECT `customers`.* FROM `customers` WHERE `customers`.`my_text_field` = '05007062' LIMIT 1
ActiveRecord::StatementInvalid: Mysql2::Error: Invalid date: 2012-00-00 00:00:00: SELECT `customers`.* FROM `customers` WHERE `customers`.`my_text_field` = '05007062' LIMIT 1
...
Does anyone know why could that be? I don't see any date in the query. Also, this happens only in production and not on development machine (both running linux).
I'm using Rails 3.1.0 and mysql2 0.3.10
Sounds like you may have some corrupted data in one of the records on your prod server. Do you have some other code that creates records in the db - including a date?