Answer the question
In order to leave comments, you need to log in
Is it possible to select a row with a single request by the condition of the presence of the required ID in the field if the IDs are written separated by commas in one line?
Good evening.
There is a field ids (table A), in which IDs of records of another table B are listed, separated by commas. I am trying to display all fields in which B.id values will be present in A.ids with one request. In the evening, I don’t understand at all - LOCATE in this situation is poorly suited (you will have to run at least 2-3 checks), procedures (to break the field value with IDs into an array and use the IN operator) are more likely not an option than an option, because program execution priority. Is there a nice way to solve the problem?
The database engine is sqlite .
Answer the question
In order to leave comments, you need to log in
If I understand correctly and look for id=5:
SELECT * FROM A where A.ids = '5' OR A.ids like '5,%' OR A.ids like '%,5,%' OR A.ids like '%,5'
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question