AM using MySQL 5.7.13 on my windows PC with WAMP Server
Here my Problem is While executing this query
SELECT *
FROM `tbl_customer_pod_uploads`
WHERE
Open you WAMP panel and open MySQL configuration file. In it search for "sql_mode" if you find it set it to "" else if you don't find it add sql_mode="" to the file.
Restart the MySQL server and you are good to go...
happy coding.
When MySQL's only_full_group_by
mode is turned on, it means that strict ANSI SQL rules will apply when using GROUP BY
. With regard to your query, this means that if you GROUP BY
of the proof_type
column, then you can only select two things:
proof_type
column, or
By "aggregates" of other columns, I mean using an aggregate function such as MIN()
, MAX()
, or AVG()
with another column. So in your case the following query would be valid:
SELECT proof_type,
MAX(id) AS max_id,
MAX(some_col),
MIN(some_other_col)
FROM tbl_customer_pod_uploads
WHERE load_id = '78' AND
status = 'Active'
GROUP BY proof_type
The vast majority of MySQL GROUP BY
questions which I see on SO have strict mode turned off, so the query is running, but with incorrect results. In your case, the query won't run at all, forcing you to think about what you really want to do.
Note: The ANSI SQL extends what is allowed to be selected in GROUP BY
by also including columns which are functionally dependent on the column(s) being selected. An example of functional dependency would be grouping by a primary key column in a table. Since the primary key is guaranteed to be unique for every record, therefore the value of any other column would also be determined. MySQL is one of the databases which allows for this (SQL Server and Oracle do not AFAIK).
> sudo nano /etc/mysql/my.cnf
Enter below
[mysqld]
sql_mode = ""
Ctrl + O => Y = Ctrl + X
> sudo service mysql restart
go to the phpmyadmin and open the console and execute this request
SET GLOBAL sql_mode=(SELECT REPLACE(@@sql_mode,'ONLY_FULL_GROUP_BY',''));
I had similar problem with part of my database crushing. What I did is I changed the parameter in the DB via PHPStorm database console like this:
SET GLOBAL sql_mode=(SELECT REPLACE(@@sql_mode,'ONLY_FULL_GROUP_BY',''));
works like charm now
In Ubuntu
Step 1:
sudo vi /etc/mysql/mysql.conf.d/mysqld.cnf
Step 2: Go to last line and add the following
sql_mode = ""
Step 3: Save
Step 4: Restart mysql server.