I have a table that is populated with raw data on a pass by an extraction program. Its other fields are left NULL and a secondary program parses through this data to fill in the other fields. I would like to move some of this logic out of the second program and into SQL statements, but it seems less than encouraging.
create table Data ( ID int unsigned not null auto_increment primary key, TypeID tinyint unsigned null, Raw varchar(100) ); create table Types ( ID tinyint unsigned not null auto_increment primary key, Name varchar(10) ); # Program 1: INSERT INTO Data(Raw) values ("Apple"), ("Orange"), ("Potato"); # Pre-existing data: INSERT INTO Types (Name) values ("Fruit"), ("Vegetable"), ("Other"); # Program 2: while ($data = each(query("SELECT ID, Raw from Data where TypeID is NULL"))) { # if $data["Raw"] contains "Apple" or "Orange" or "Kiwi" then set TypeID = ID for Fruit. } ... Could I make my life any simpler by making a cross-reference table, etc.? I'm feeling a bit stuck; all my logic for this is currently in a program instead of on the DB side. -- Michael T. Babcock C.T.O., FibreSpeed Ltd. http://www.fibrespeed.net/~mbabcock --------------------------------------------------------------------- Before posting, please check: http://www.mysql.com/manual.php (the manual) http://lists.mysql.com/ (the list archive) To request this thread, e-mail <[EMAIL PROTECTED]> To unsubscribe, e-mail <[EMAIL PROTECTED]> Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php