I'm begging here. Below is a Visual Fox Pro script (just part of it actually). Anyway, I can't for the life of me figure out to get this to work in MySql. This would be run daily against a 100K+ records. The part of it that is tricky (for me) is setting the variable value, since the record order is critical to the script (the data is imported daily from another ancient program). I tried setting the variable within an UPDATE query, but I can't get it to work. I assume that this should be in a procedure? Can some MySQL luminary give this a stab?
DO WHILE !EOF()
IF bnote='***********' AND SUBSTR(bpart,1,3)='EAR' AND m.bldtype<>'EAR'
IF bnote='***********' AND SUBSTR(bpart,1,3)='KIT' AND m.bldtype<>'KIT'
IF bnote='***********' AND m.bldtype='KIT' AND EMPTY(bpart) AND m.bldtype<>'MISC'
REPLACE bldtype WITH 'BLD'
REPLACE bldtype WITH 'EAR'
REPLACE bldtype WITH 'KIT'