-
Notifications
You must be signed in to change notification settings - Fork 453
[MySQL 5.7] ORDER BY clause is not in SELECT list #376
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Hi @rp1428 so MySQL 5.7 has added such a constraint... (I think PostrgreSQL already had it). We will have to manage it seriously! As you can see on the SQL query you have found, the order_by is a variable, so we will have to select rows as a variable... |
much simpler solution : do not query with DISTINCT and remove duplicates in PHP |
@mistic100 of course, much simpler. And I doubt it would make things much slower (fetching some ids should be fast) |
I think for large galleries it will definitely be slower (I'm thinking of And I'm definitely sure there are many other places... Do you know if this is going to be the future mysql standard or just some
|
Researching, I came across: As of MySQL 5.7.5, the default SQL mode includes ONLY_FULL_GROUP_BY. (Before 5.7.5, MySQL does not detect functional dependency and ONLY_FULL_GROUP_BY is not enabled by default. For a description of pre-5.7.5 behavior, see the MySQL 5.6 Reference Manual.) And my database has: So perhaps this is the culprit, the default is ONLY_FULL_GROUP_BY. I can try changing this tonight to see if it removes the issue. |
It makes me think of http://piwigo.org/bugs/view.php?id=3205 which shows that MySQL 5.7 has new default settings, with more restrictions. But I doubt hosting providers will keep these default settings, or else many web applications will be broken. |
I set sql-mode="" in /etc/my.cnf and that resolved the issue for me. This email has been checked for viruses by Avast antivirus software. |
I just ran into this after upgrading my server today to Ubuntu 16.04, which came with MySQL 5.7.11-0ubuntu6. When I try to browse my albums I get:
|
Adding
to my.cnf resolved my issue. The problem seems to be related to the default ONLY_FULL_GROUP_BY setting in mysql 5.7. |
That's exactly what was said above :-) |
Yep, I know. I was just confirming that workaround since this issue is still marked as open. |
This still seems to be an issue (fresh install on ubuntu 16.04), I can confirm @jradwan 's fix works. |
^ Same here, on Ubuntu 16.04. The "sql-mode=""" fix helped me as well though. |
Add this:
To: Worked for me as well, on Ubuntu 16.04 |
Works for me on Debian 8, but I guess this is just a temporary work around? |
This workaround http://piwigo.org/forum/viewtopic.php?pid=163884#p163884 seems interesting. |
Add this: [mysqld] To: Worked for me as well, on Ubuntu 16.04 |
This is needed when sorting on a column that is not part of the projection. In MySQL 5.7 strict mode, it is now required to add all columns in the ORDER BY clause in the SELECT's projection. I could not find another way of fixing it, then adding a new parameter which can inject the required missing piece in the select clause. It's not a backward incompatible change on PHP 5.6, but can break extensions on PHP 7.0+ since method signature must remain intact. At least, the core is not broken anymore on MySQL 5.7 strict. cc @brendo cc @michael-e
Only Wamp Server [mysqld] Folder Path: It is working in window 7 and 8. |
For me, its simpler to fix the "offending" SQL statement. This is an easy change from:
to:
Just match the select with the order by and you're good to go. |
The problem was fixed with b87094a |
Another solution: |
*Another solution: This work for me. *The problem was fixed with b87094a = Result Error 500
|
DON'T USE:
From documentation: By setting I don't care about the other settings so I ended up with:
|
Hey gang, MySQL version: Listen I hope it's not too late, but as many of you I wouldn't like to temper with the workaround, I confirm it's working but I would rather fix my query to work. So from the simple query which was earlier:
I got the error: So I rewrote it with the subquery. My solution would be:
I hope it will help somebody. |
I edited this file
Compared with the default sql_mode, I just removed 'ONLY_FULL_GROUP_BY' mode and it fixed the problem for me. |
This worked for me: For people using MAMP (free)(MacOS): Steps -> Stop your servers -> you might need to create a the file my.conf in your /MAMP/conf/ directory if its not already there and put this lines and then try starting servers.. Hope it helps. |
working 4 me to |
Hello, Editing my.cnf or using SET @@global.sql_mode=(SELECT REPLACE(@@global.sql_mode, 'ONLY_FULL_GROUP_BY', '')); is only applicable when having full right on your mysql instance :/ For exemple, on the new DB services on OVH, it's not usable. It seems that there is a solution here : #376 (comment) but it's not yet implemented :( |
I get an error 3065 regardless of which ordering option I select in configuration. I narrowed it down to:
mysql> SELECT DISTINCT(image_id)
-> FROM piwigo_image_category
-> INNER JOIN piwigo_images ON id = image_id
-> WHERE
-> category_id = 6178
->
-> ORDER BY piwigo_images.file ASC;
ERROR 3065 (HY000): Expression #1 of ORDER BY clause is not in SELECT list, references column 'piwigo.piwigo_images.file' which is not in SELECT list; this is incompatible with DISTINCT
The above is from mysql - the browser reports a similar error. To get past this, I changed section_init.inc.php and added piwigo_images.file to the select line to force it for my site.
SELECT DISTINCT(image_id),piwigo_images.file
FROM '.IMAGE_CATEGORY_TABLE.'
INNER JOIN '.IMAGES_TABLE.' ON id = image_id
WHERE
'.$where_sql.'
'.$forbidden.'
'.$conf['order_by'].'
;';
Server version: 5.7.9 MySQL Community Server (GPL)
Piwigo 2.7.4
The text was updated successfully, but these errors were encountered: