php - How to merge these two queries into one? -
quite simply... how can merge these 2 queries one?
$sql = "update `data` set `views` = `views` + 1 `id`=$id , `source`='$source' , `keyword`='$keyword'"; $sql = "update `settings` set `count` = `count` + 1 `id`=$id";
edit:
also, there's matter of first time data entered, when data update not yet exist in data table.
my insert query:
$sql = "insert `_data` (`id`, `source`, `keyword`, `views`) values ($id,'$source','$keyword',1)";
is possible combine insert of new data 1 table, update table?
i suggest use prepared statements.
$sql = "update data, settings set data.views = data.views+1, settings.count = settings.count+1, data.id = $id , data.source = $source , data.keyword = $keyword , settings.id = $id";
Comments
Post a Comment