MySQL Forums
Forum List  »  PHP

Finding matches in a table and then moving that match to another table???
Posted by: Christopher E
Date: March 31, 2006 06:29PM

Hello All,


Ok, I have a database that has three tables in it.
The three tables are:
filtering_criteria_table
blocked_ business_table
business_data_table
unprocessed_data_table

The table called filtering_criteria_table (fct) has two fields in it
Criteria_ID
Criteria_Data

In the other three tables have the same fields and I won't list them all here but four of them:
EIN
NPO
Active_Code
NTEE

Now what I would like to happen is take the data from the unprocessed_data_table and do:
1. check to see if the EIN is not listed in the blocked_business_table if it is then delete it from the unprocessed... table!
2. if its not listed in block table then check agaist the crieria table if match of any then move to business_data_table
3. the ones that don't match any criteria goes to a table called blocked_business_table as there don't need to be looked at and are not needed and only the EIN number is kept and the rest is deleted.

I know how to open a connection, close, select

but I don't know how I would inside of a database use another one as
the way to create the list of criteria. Now please not that I am NOT using the full names of even the names that I will use as they would mean nothing at all to any of you for the most part as their are shortcut names that I made up.

if I am right, I would create say a var
$query = "SELECT critiera_check_table FROM criteria
$criteria = mysql_query($query) or die('Error, Query failed');

Now I think I would do some thing like this:
$query = "SELECT nfnp_table FROM (NPO, NTEE) WHERE $criteria
$criteria = mysql_query($query) or die('Error, Query failed');

now this is what I don't get, how can I tell it how to look for what
the criteria is.

some I want to look for using %criteria% others are exactly like G41.

Should I in the table wrap the criteria information with the thing I
want so in the case of %% I would in the database write in like this
" %dog% " or " 'G41' or 031 (these are the three types of things I
would be search but there is as of now 25 different criteria and if it
meets only one or more of them then I want it. Now if there is two
words that I want together in the database I would write like this "
%dog AND cat% " I put in the % still because it could be at the
begging or end or even in the middle still but I want the to words in
the match?

If any one could give a example that would be great!

Thanks for helping and if I miss some thing or have question to ask
please do so!

Sincerely,
Christopher & Missy

Options: ReplyQuote


Subject
Written By
Posted
Finding matches in a table and then moving that match to another table???
March 31, 2006 06:29PM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.