Home:ALL Converter>Port MySQL query to PostgreSQL

Port MySQL query to PostgreSQL

Ask Time:2012-08-05T02:08:13         Author:Vilva

Json Formatter

I'm migrating my MySQL databases to PostgreSQL. While connecting database to my Python script I'm getting some syntax error. So could you please convert this MySQL query into PostgreSQL:

select ifnull((select ifnull(run_id,0) from searchbank order by run_id desc limit 0,1),0)

Author:Vilva,eproduced under the CC 4.0 BY-SA copyright license with a link to the original source and this disclaimer.
Link to original article:https://stackoverflow.com/questions/11810898/port-mysql-query-to-postgresql
Gordon Linoff :

Postgres doesn't support ifnull:\n\nselect coalesce((select coalesce(run_id,0)\n from searchbank\n order by run_id desc limit 0,1),0\n )\n\n\nYou might find this version slightly cleaner and clearer:\n\nselect coalesce(max(run_id), 0)\nfrom searchbank\n",
2012-08-04T18:12:49
yy