select and insert in one command

admin

Administrator
Staff member
is there anyay, for MySQL to combine this into one statment. Seems silly to have extra statment to check if the user exists already.


// check to make see if the user id exists already
$qry = \"select from table id where username=\'$username\'\";
$mysql->query($qry);

if (!mysql_affeted_rows) {
$qry = \"insert into table whatever . .\"
$mysql->query($qry);
}
 
Back
Top