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
Turn off only_full_group_by only if you know what you're doing!
A simple example to demonstrate the issue:
Table: users
id | name
----------------
1 ali
2 john
3 ali
When you use GROUP BY on name column:
SELECT * FROM users GROUP BY name;
There are two possible results:
1 ali
2 john
OR
2 john
3 ali
MYSQL does not know what result to choose! Because there are different ids but both have name=ali.
Solution1:
only selecting the name field:
SELECT name FROM users GROUP BY name;
result:
ali
john
Solution2:
Turning off only_full_group_by. MYSQL will show you one of the two possible results I showed earlier RANDOMLY!! (It's ok if you do not really care what id it will choose)
Solution3
Use an Aggregate function like MIN(), MAX() to help MYSQL to decide what it must choose.
for example I want the minimum id:
SELECT MIN(id), name FROM users GROUP BY name;
result:
1 ali
2 john
It will choose the ali row which has the minimum id.