I need to perform search on a table by implementing an algorithm(either in the front end java code or in the back end sql query I write). For your reference, I have pasted the sql code for the table I am using.
CREATE TABLE "tbl_reference_databases" (
"id" integer primary key autoincrement,
"created" datetime DEFAULT NULL,
"modified" datetime DEFAULT NULL,
"refdata_content_code" varchar(10) DEFAULT NULL,
"refdata_profession_passion_code" varchar(10) DEFAULT NULL,
"refdata_attribute_code" varchar(8) DEFAULT NULL,
"refdata_sex_code" varchar(1) DEFAULT NULL,
"refdata_age_code" varchar(2) DEFAULT NULL,
"refdata_location_code" varchar(4) DEFAULT NULL,
"refdata_language_code" varchar(4) DEFAULT NULL,
"refdata_foodhabit_code" varchar(1) DEFAULT NULL,
"refdata_drinkhabit_code" varchar(1) DEFAULT NULL )
From this table, I need to get the value corresponding to 'refdata_content_code' . The fields that would be included in WHERE clause is :
The requirement with this search is, I need to have an algorithm such that, I could prioritize the results based on the number of fields included in the WHERE clause. If the WHERE clause involves all the 8 fields, then the result I get for 'refdata_content_code' could be prioritized as 1, and after that remove fields one by one in the WHERE clause.
Finally, if I get a result with a single field in the WHERE clause, that is the last priority result.
So, the first WHERE clause would include all the fields given above and after that, fields would be removed one by one in the ascending order of the fields given above.
I am not sure, whether this could be achieved with a single query or multiple queries. I do not even know what is the best approach I should use.
The front-end code I use is java.
Any help from the EE experts who could help me implement this algorithm would be much appreciated with points, surely.
If I need to clarify any portion of my question, kindly let me know.