Last post Dec 14, 2016 11:53 AM by Eric Du
Dec 01, 2016 06:15 PM|peterthegreat|LINK
I have a select statement as such:
SELECT CategoryDescription, PRODUCTDESCRIPTION, Category
WHERE PRODUCTDESCRIPTION LIKE '%foo%'
the problem is PRODUCTDESCRIPTION contains a comma delimited string like : footware,trainers,pumps
I want to retrieve the matching word 'footware' from the input search string term %Foo% using SQL.
My objective is to build a path like: Cloths\Footware\Trainers from the SQL result ?
Dec 02, 2016 06:25 AM|Eric Du|LINK
According to your description, you can select PRODUCTDESCRIPTION in string format, then operate it in c#, here is the sample code, you can refer to this sample:
protected void Button1_Click(object sender, EventArgs e)
string a = "footware,trainers,pumps";
string b = a.Split(',');
string c = b.Select(x => x.Contains("foo") ? x : "").ToArray();
foreach (var item in c)
Dec 04, 2016 09:09 PM|peterthegreat|LINK
You dont know the vb way of hand do you ?
Dec 14, 2016 11:53 AM|Eric Du|LINK
This is the VB version., Please check it:
Protected Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Dim a As String = "footware,trainers,pumps"
Dim b As String() = a.Split(","c)
Dim c As String() = b.[Select](Function(x) If(x.Contains("foo"), x, "")).ToArray()
For Each item As String In c