If you mean that the tickets should be booked and the tickets_remaining should be subtracted there is no way to do it with one query. Of course you could use a trigger to do it from the database, but normally I think it's easier to do from PHP.
If you mean that you want one query to update the number of tickets remaining it is quite easy:
$sql "UPDATE `db_affiliate_codes` SET `tickets_remaining` = tickets_remaning - 1 WHERE `id` =1 LIMIT 1 ;";";