php - Select and Update in same query -
can select , update in same query? i'm trying count views create top blog posts views sidebar.
$sql = mysql_query("select * articles id='$id' limit 1 update pages set views=views+1 id=$id");
no, cannot that, there nothing wrong doing 2 queries.
mysql_query("update pages set views=views+1 id=$id"); $sql = mysql_query("select * articles id=$id");
also, if id
primary key don't have limit 1
here, id
unique, therefore have 1 result matching condition.
Comments
Post a Comment