Selecting rows based on values ​​in one of the comma-delimited columns: PL / SQL

I am currently trying to select all rows that have a specific identifier in the column identifier column with semicolon delimited columns.

Table:

=====================
 TOOL_ID | TOOL_USERS
---------------------
    1        1;2;3
    2        1;3
    3        1
=====================

I want to select all the tools that a specific user has access to, for example, the desired result when the user ID is 3:

TOOL_ID | TOOL_USERS
---------------------
    1        1;2;3
    2        1;3

I know that this project is not standardized, but I do not have the ability to modify / modify the database. I could always just query all the rows and then skip the results, deleting all that don't contain the user id, but I would rather do this, this is a nice, clean query.

Is it possible? Thank.

+4
1

LIKE . , 13 3.

SELECT TOOL_ID, TOOL_USERS FROM YourTable WHERE ';' || TOOL_USERS || ';' LIKE '%;3;%'

- , PLSQL.

+4

Source: https://habr.com/ru/post/1683756/


All Articles