I am trying to create an IF ELSE statement in MySQL to update a table using data from another table.
BEGIN
IF owners.ab = '' THEN
SET owners.ben = ditches.min * 3 FROM owners, ditches
WHERE owners.number = '566' AND owners.number = ditches.number
ELSE
SET owners.ben = owners.ab * ditches.acre * 3 FROM owners, ditches
WHERE owners.number = '566' AND owners.number = ditches.number
END IF;
I get an error, of course
#1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'IF ab = '' THEN SET ben = min * 3 FROM owners, ditches WHERE owners.number =' at line 2
Sadly this explanation is past my understanding. http://dev.mysql.com/doc/refman/5.0/en/if-statement.html
Can someone please help me break this down and understand how this works??
Thank you!