I have the following prepared query I am using with mysql and php. It is to allow users to be added to a particular category, passed in via $subcat.
$alterQuery = "UPDATE AUCTIONS SET subcat= ? WHERE article_no= ?";
if ($altRecord = $con->prepare($alterQuery)) {
$altRecord->bind_param("ss", $subcat, $pk);
$altRecord->execute();
$altRecord->close();
echo "true";
}
What I would like to do, in the same query, is insert a new record in the USERS table only inserting the username, after checking that the username does not already exist. Is it possible just to change $alterQuery to:
What is the best what to do this?
Check for the username, and if it == null, do a subsequent insert? can I have two different queries executed in the same if block?
edit: attaching database scheme in response to comment
AUCTIONS
ARTICLE_NO varchar(20) primary key
ARTICLE_NAME varchar(100)
SUBTITLE varchar(20)
CURRENT_BID decimal(5,2)
START_PRICE decimal(5,2)
BID_COUNT varchar(20)
QUANT_TOTAL varchar(20)
QUANT_SOLD varchar(20)
ACCESSSTARTS varchar(30)
ACCESSENDS varchar(20)
ACCESSORIGIN_END varchar(20)
USERNAME varchar(20)
BEST_BIDDER_ID varchar(20)
FINISHED tinyint(4)
WATCH tinyint(4)
BUYITNOW_PRICE decimal(5,2)
PIC_URL varchar(120)
PRIVATE_AUCTION tinyint(4)
AUCTION_TYPE varchar(20)
ACCESSINSERT_DATE varchar(20)
ACCESSUPDATE_DATE varchar(20)
CAT_DESC varchar(20)
CAT_PATH varchar(20)
ARTICLE_DESC text
COUNTRYCODE varchar(20)
LOCATION varchar(20)
CONDITIONS varchar(20)
REVISED tinyint(4)
PAYPAL_ACCEPT tinyint(4)
PRE_TERMINATED tinyint(4)
SHIPPING_TO varchar(20)
FEE_INSERTION decimal(5,2)
FEE_FINAL decimal(5,2)
FEE_LISTING decimal(5,2)
PIC_XXL tinyint(4)
PIC_DIASHOW tinyint(4)
PIC_COUNT varchar(20)
ITEM_SITE_ID varchar(20)
STARTS datetime
ENDS datetime
ORIGIN_END datetime
SUBCAT varchar(20)
USERS
username varchar(30) primary key
firstname varchar(30)
lastname varchar(30)
flaggedauctions varchar(30)
lastauction varchar(30)
street1 varchar(30)
city1 varchar(30)
postcode1 varchar(30)
street2 varchar(30)
city2 varchar(30)
postcode2 varchar(30)
phone varchar(30)
mobilephone varchar(30)
fax varchar(30)
email varchar(30)
website varchar(30)
bank varchar(30)
banknumber varchar(30)
accountnumber varchar(30)
comments varchar(30)