Summary of the problem:
I use Python to send a series of queries to the database (one after the other) from the loop until a nonempty result set is found. The request has three conditions that must be met, and they are placed in the where statement. Each iteration of the cycle changes and controls the conditions from a specific condition to a more general one.
Details:
Assuming conditions are keywords based on a pre-prepared list ordered by accuracy, for example:
Option KEYWORD1 KEYWORD2 KEYWORD3
1 exact exact exact
2 generic exact exact
3 generic generic exact
4 generic generic generic
5 generic+ generic generic
.... and so on.
On the database side, I have a description column that should contain all three keywords, either in their specific form or in general form. When I run the loop in python, this is what actually happens:
Select *
From MyTable
Where Description LIKE 'keyword1-exact$'
AND Description LIKE 'keyword2-exact%'
AND Description LIKE 'keyword3-exact%'
Select *
From MyTable
Where Description LIKE 'keyword1-generic%'
AND Description LIKE 'keyword2-exact%'
AND Description LIKE 'keyword3-exact%'
Select *
From MyTable
Where Description LIKE 'keyword1-generic%'
AND Description LIKE 'keyword2-generic%'
AND Description LIKE 'keyword3-exact%'
, ( , , )
:
, , , .
Python (, , )?