I'm trying to create a MySQL command where it will look at the value alpha of table A to see if the ip address has already been written.
If it has not been written I would like to create a new row with that ip and values alpha and beta.
If it has already been written I would like to increase value alpha by one and perform the calculation alpha/beta and set gamma to equal that.
I know how to read and write statements, but I have no clue how to conditional conditional statement ("if ip already exists") or perform calculations inside the table.
Is there an efficient way in MySQL to do this?
What I have below is a simple write command to log the ip address. It does not check to see if it already exists, and currently creates duplicate records.
mysql_query("INSERT INTO a (ip, alpha, beta, gamma) VALUES ('$REMOTE_ADDR', 'B', 'C', 'D')");