I'm converting a PHP script as DB has been switched from MySQL to PostgreSQL.
I know PG doesn't have the IF function but does have the CASE function. What is the best way to convert this MySQL statement?
SELECT albums.id,
albums.albumname,
sum(if(((albums.id=allalbums.albumid) and
(allalbums.photoid=$photoid)),1,0)) as inalbum
FROM albums, allalbums
GROUP BY albums.id
ORDER BY albums.createdate desc