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,
);
source
share