I am facing some trouble writing where condition in the SQL select statement match the above criteria. Any advice?
AllCompany = AllCompany
.Where(company =>fldSector
.Contains(company["Sectors"].Replace("|", ","))).ToList();
There is a REPLACE() function in sql-server and it would probably look like this if you do updating
on your table:
UPDATE tableName
SET sectors = REPLACE(sectors,'|',',');
See Fiddle Demo
Or if you want simply to SELECT
, you can use PATINDEX()
:
SELECT sectors
FROM tableName
WHERE PATINDEX('%|%',sectors) > 0
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.