I have a difficult problem that I'm not quite sure how to handle.
I define two subsets of values ββfrom the same table that match certain criteria.
operator 1:
SELECT value FROM Values WHERE category = a
statement 2:
SELECT value FROM Values WHERE category = b
But I also have an additional restriction, which is that any value from operator 1 concatenated with any value of operator 2 must contain a string whose length must be equal to or less than the specified maximum length of the string.
What request can I write for this? Thanks in advance for your help.
Lothaire
Edit:
My data is as follows:
+---+---------+------------+----------+ |id | routeId |category | value | +---+---------+------------+----------+ | 1 | 1 |origin | Paris | | 2 | 1 |destination | New York | | 3 | 2 |origin | Paris | | 4 | 2 |destination | Berlin | +------+--------------+---------------+
And I would like to get a list of routeId for routes where origin.destination is less than n characters.
Now, when I look more closely at this problem, I see that my initial approach was wrong, because I wrote that any value from the first select statement associated with any value from the second select statement must have a length under a certain restriction sign. In fact, the problem is more complicated, because routeId for the origin value and the target value should be the same for a pair of values, the concatenation of which should be no more than maximum.
source share