Check row values and if 2 fields in a single row match values I'd be inserting, modify it, otherwise, create a new row.. but how?
Posted on 2011-09-11
I have a 'subscriber' table that contains the phone number they subscribed with and what account it belongs to. The subscriber can change his subscription status by text message. What I'm having trouble with is ensuring that there is only one row that contains that phone number associated to that particular account id.
Lastly the subscriber could possibly subscribe to more than one account.
So: how does one go about creating a query when doing an insert or what have you that checks the account id and the phone number and if they exist together, it updates the values, otherwise, if they don't exist together, they create a new row?
I can access the 2 variables for the query fine (that being account_id and CallFrom), just don't know how to compare/update/insert.
Thanks for your help.