string shape = " 'round', ' pearl', 'oval', 'heart', 'princess' ";
// first query - select * from table1 where shape in (" + shapes + ")
// second query - select * from table1 where shape like '%Pear%'";
now i want to use 'like' parameter for all other shape.
in short how can i use combination of 'like' and 'in' operator.
Thanks in advance.
in short how can i use combination of 'like' and 'in' operator.
Thanks in advance.
VulpesPosted Jun 13, 2014, 10:01 AM
When I put the code I posted earlier into a program and run it:
using System;
using System.Text.RegularExpressions;
class Program
{
static void Main()
{
string shape = " 'round', 'pearl', 'oval', 'heart', 'princess' ";
string temp = Regex.Replace(shape, @"\w+", "%$0%");
string[] shapes = Regex.Split(temp, ",");
temp = "shape like" + String.Join(" or shape like", shapes);
string query = "select * from table1 where " + temp.Trim() + ";";
Console.WriteLine(query);
}
}
the output is:
select * from table1 where shape like '%round%' or shape like '%pearl%' or shape
like '%oval%' or shape like '%heart%' or shape like '%princess%';
which is what I thought you wanted here?
prince rajPosted Jun 13, 2014, 9:35 AM
http://www.c-sharpcorner.com/Forums/Thread/258515/two-string-in-where-condition-for-one-column.aspx
Thanks
prince rajPosted Jun 13, 2014, 9:13 AM
this work on single selection, when more than two shape are selected its not return any row.
??????????
VulpesPosted Jun 12, 2014, 5:32 AM
Bhabani PrasadPosted Jun 12, 2014, 5:09 AM
VulpesPosted Jun 12, 2014, 4:57 AM
//.....
prince rajPosted Jun 12, 2014, 12:38 AM
But i dont know how many and which shapes are in string.
so how can i check like operator with all them ?
VulpesPosted Jun 11, 2014, 12:23 PM
prince rajPosted Jun 11, 2014, 8:10 AM
like '%round%', '%pearl%', '%oval%', '%heart%', '%princess%'
-----------------------------
Thanks.
sudipta sanyalPosted Jun 11, 2014, 7:15 AM