Query:
SELECT *
FROM Post
ORDER BY Post.rating <-- Here , i want ( Post.rating * 5 ) when Post.recommended = 1 )
Thanks all people.
Query:
SELECT *
FROM Post
ORDER BY Post.rating <-- Here , i want ( Post.rating * 5 ) when Post.recommended = 1 )
Thanks all people.
Use:
SELECT p.*
FROM POST p
ORDER BY CASE
WHEN p.recommended = 1 THEN p.rating * 5
ELSE p.rating
END
SELECT * FROM Post
ORDER BY case Post.rating when 1 then post.rating * 5 else post.rating end
Does this work?
SELECT *
FROM Post
ORDER BY CASE Recommended WHEN 1 THEN Rating * 5 ELSE Rating END
Since there's only one table, the column references are unambiguous, so I removed the Post.
prefixes, which avoids the horizontal scroll-bar.
SELECT *
FROM Post
ORDER BY Post.rating * IF(recommended = 1, 5, 1)
try
SELECT *
FROM Post
ORDER BY if(Post.recommended = 1,Post.rating * 5,Post.rating)