spiritssight Posted February 4, 2008 Share Posted February 4, 2008 Hello I have this piece of code that I would like to make pure sql and I am not sure what the best way to do this would be. Please assist with this as its for a non-profit project. What i am trying to do is: 1. look in the block table if its in there then delete it from irs_rawdata 2. look in irs_rawdata for match of rules (WHERE) and insert into query 3. take the rest of irs_rawdata and insert into block the EIN into a field called fin and also add a value to the who_blocked field S-123456789 4. delete the records that was added to the block table from the irs_rawdata table so its empty to my best ablility the below code appears to work but I know this code could be rewritten to be better. Sincerely, Christopher DELETE FROM irs_rawdata WHERE EXISTS ( SELECT fin FROM block ); INSERT INTO query SELECT * FROM irs_rawdata WHERE PNO LIKE '%blind%' OR PNO LIKE '%deaf%' OR NTEE_Code LIKE '%P87%'; INSERT INTO block SELECT EIN FROM irs_rawdata WHERE NOT EXISTS PNO LIKE '%blind%' OR PNO LIKE '%deaf%' OR NTEE_Code LIKE '%P87%'; DELETE FROM irs_rawdata WHERE NOT EXISTS ( SELECT PNO, Activity_Code, NTEE_code FROM irs_rawdata WHERE PNO LIKE '%blind%' OR PNO LIKE '%deaf%' OR NTEE_Code LIKE '%P87%' ); Quote Link to comment https://forums.phpfreaks.com/topic/89311-solved-parsing-data-with-sql-only/ Share on other sites More sharing options...
fenway Posted February 4, 2008 Share Posted February 4, 2008 Why so complicated? Quote Link to comment https://forums.phpfreaks.com/topic/89311-solved-parsing-data-with-sql-only/#findComment-457560 Share on other sites More sharing options...
spiritssight Posted February 4, 2008 Author Share Posted February 4, 2008 Why so complicated? what do you mean? it is part of a parsing script that runs automatic and is all sql, like there is a load data and then there is a clean white space then the code that I have posted Sincerely, Christopher Quote Link to comment https://forums.phpfreaks.com/topic/89311-solved-parsing-data-with-sql-only/#findComment-458075 Share on other sites More sharing options...
fenway Posted February 4, 2008 Share Posted February 4, 2008 It seems like there's an intermediate step in there. Quote Link to comment https://forums.phpfreaks.com/topic/89311-solved-parsing-data-with-sql-only/#findComment-458097 Share on other sites More sharing options...
spiritssight Posted February 4, 2008 Author Share Posted February 4, 2008 Sorry I don't understand what you mean, could you please explain more. Sincerely, Christopher Quote Link to comment https://forums.phpfreaks.com/topic/89311-solved-parsing-data-with-sql-only/#findComment-458106 Share on other sites More sharing options...
fenway Posted February 5, 2008 Share Posted February 5, 2008 Maybe I just don't understand your "block" concept. Quote Link to comment https://forums.phpfreaks.com/topic/89311-solved-parsing-data-with-sql-only/#findComment-458627 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.