Order by calls a select request to return null values

The mysql query below works fine if I don't use ORDER BY CLAUSE .

However, as soon as I insert an order within the value to return the pictureRating values (i.e. users with the highest quality images), then the query will stop returning all the values, for example, it will stop returning any values ​​from the binding table.

SELECT u.id,st.message,ph.image
FROM user u  
LEFT OUTER JOIN statement st ON u.id = st.id
LEFT OUTER JOIN photosGallery ph ON u.id = ph.userId
WHERE u.live = 1 
GROUP BY u.id 
ORDER BY u.pictureRating DESC 

the following tables:

user.

 CREATE TABLE users(
id MEDIUMINT UNSIGNED NOT NULL AUTO_INCREMENT,
pictureRating smallint(6) NULL, 

); 

PHOTO Gallery

CREATE TABLE photosGallery(
id MEDIUMINT UNSIGNED NOT NULL, 
image  VARCHAR(30) NULL
); 

operator

CREATE TABLE statement (
id MEDIUMINT UNSIGNED NOT NULL,
message VARCHAR (60) NULL,
); 
+1
source share
1 answer

GROUP BY. , SELECT GROUP BY ( , ), . , MySQL ( , , ) , . BTW, , ONLY_FULL_GROUP_BY sql_mode.

, , "" . MIN() MAX(), , . NULL.

0

Source: https://habr.com/ru/post/1612378/


All Articles