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

Popular posts from this blog

javascript - Count length of each class -

What design pattern is this code in Javascript? -

hadoop - Restrict secondarynamenode to be installed and run on any other node in the cluster -