I am passing values in a POST and have no idea if a record with some of the data exists already in the table.
here is the post:
$t = $_REQUEST["teamid"];
$n = $_REQUEST["name"];
$j = $_REQUEST["jersey"];
$a = $_REQUEST["age"];
Now, there will be 1 or more name, 1 or more jersey and one or more age values.
teamid will have one and only one value.
Now. when trying to insert/update the values, how would I do this?
In SQL Server, I can use an
if EXISTS(SELECT count FROM table WHERE name=:name) > 0
BEGIN
-- DO update here
END
ELSE
BEGIN
-- DO insert here
END
How to do this in mySQL?
REPLACE INTO and DUPLICATE KEY UPDATE don't look like they'll help here.
REPLACE INTO is slow and DUPLICATE KEY UPDATE won't work because we are
not sending the key value in the POST.