I have a request that is not in any way. This is quite dynamic, and the way it is because of use in my application. In short, it allows the user to select the fields that they want to see in the report, and also to determine the logic (WHERE clause) and, finally, what order they want to sort.
To make this easier, I created an idea of all the data that could be included in the report. Thus, he simply selects the fields that the user wants and requests a view.
I came across an instance where, instead of individual data points, I have several situations 1:many. An example is the list of affected countries. In my opinion, this is a comma separated list United States, United Kingdom, Etc. This data is simply populated and separated by commas in the creation of the views.
Question
When creating this, I intended to simply use a statement INfor the data. Then I realized that it INis only a table function and cannot be used for a data row.
Is there a way to take a value and compare it with a comma-separated data string?
I tried to create a SQL script, but the site crashed all the time.
CREATE TABLE Test (country varchar(100), account INT);
INSERT INTO Test ('United States, United Kingdom', '123');
INSERT INTO Test ('United States', '123567');
INSERT INTO Test ('United States, China, Japan', '123567');
I tried to use LIKE %country%, but it doesn’t work the same way as INsince I return data that I don’t need if part of the country is in a different country name.
- , , IN, , ?