bayswater Posted January 27, 2011 Share Posted January 27, 2011 Hi experts, I have this update, which DOESN'T work when my page hooks up to a postgres database: pg_query("UPDATE ".$prefix."course c INNER JOIN ".$prefix."course_categories cat ON c.category = cat.id SET c.visible = '1' WHERE c.category = '".$vist."' AND c.visible = '0' AND c.category <> '0'"); Is there a conflict with the JOIN in an update when it comes to postgres, or...? My identical code for Mysql is working fine: mysql_query("UPDATE ".$prefix."course c INNER JOIN ".$prefix."course_categories cat ON c.category = cat.id SET c.visible = '1' WHERE c.category = '".$vist."' AND c.visible = '0' AND c.category <> '0'"); Quote Link to comment https://forums.phpfreaks.com/topic/225837-join-in-update-for-postgres/ Share on other sites More sharing options...
BlueSkyIS Posted January 27, 2011 Share Posted January 27, 2011 well, the JOIN is completely unnecessary and that might be the problem with postgres. and since you already require category = '$vist', there is no need to add the condition that category != 0 $sql = "UPDATE ".$prefix."course SET visible = '1' WHERE category = '".$vist."' AND visible = '0'"; Quote Link to comment https://forums.phpfreaks.com/topic/225837-join-in-update-for-postgres/#findComment-1166092 Share on other sites More sharing options...
bayswater Posted January 27, 2011 Author Share Posted January 27, 2011 well, the JOIN is completely unnecessary and that might be the problem with postgres. and since you already require category = '$vist', there is no need to add the condition that category != 0 $sql = "UPDATE ".$prefix."course SET visible = '1' WHERE category = '".$vist."' AND visible = '0'"; Ah, yes, I get the category !=0, but I now realize that I pasted the wrong SQL I have 2 almost identical and in this second - I NEED a join (I guess?) to the categories table: mysql_query("UPDATE ".$prefix."course c INNER JOIN ".$prefix."course_categories cat ON c.category = cat.id SET c.visible = '1' WHERE cat.path like '%/".$vist."/%' AND c.visible = '0' AND c.category <> '0'"); Quote Link to comment https://forums.phpfreaks.com/topic/225837-join-in-update-for-postgres/#findComment-1166189 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.