I've a table having the columns like
Prefix CModel
g ;#WR_1;#WR_2;#WR_3;#WR_4;#
v ;#WR_3;#WR_4;#
j WR_2
m WR_1
d ;#WR_3;#WR_4;#
f9 WR_3
I want to retrieve data from all columns WHERE CModel=WR_3 from CModel.
SELECT Prefix,CModel From table1 WHERE CModel = WR_3;
It returns only one row.
Prefix CMODEL
f9 WR_3
i want it to be return 4 rows since WR_3 exists in 4 rows(contains colon delimted like ;#WR_3;#WR_4;#).How to specify that in WHERE Condition?
Given your table structure, I would use something like this:
SELECT Prefix, CModel
FROM table1
WHERE
[CModel] IS NOT NULL
AND (";" & Replace([CModel], "#", "") & ";") Like "*;WR_3;*";
Replace([CModel], "#", "")
will remove all #
characters from the model ";" & Replace(...) & ";"
will add one ; at the beginning and one ; at the end of the string Like "*;WR_3;*"
will match all strings that contain ;WR_3;
so it will also match rows that contain just WR_3
but it won't match rows that contain WR_30
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.