Is it possible to first SELECT from DB and then if something is true INSERT into db within the same query?
Here is how I do right now:
$sql = mysql_query("SELECT * FROM ".$prefix."_active_users WHERE userid = $playerid AND DATE(timestamp) = '$sel_tag'");
$row = mysql_fetch_assoc($sql);
if(!$row){
mysql_query("INSERT INTO ".$prefix."_active_users (userid,timestamp) VALUES ($playerid,'$now')");
}
Hoping for help and thanks 😉
As I read the question, you want to INSERT if no row exists.
So, in one query…
This is different to the other answers then
INSERT.. SELECT