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.

sudipta sanyalRank #1,945 · 753 reputationPosted Jun 11, 2014, 3:15 AM EDT
prince raj66 reputationPosted Jun 11, 2014, 4:10 AM EDT
like '%round%', '%pearl%', '%oval%', '%heart%', '%princess%'
-----------------------------
Thanks.
VulpesRank #55 · 29.2K reputationPosted Jun 11, 2014, 8:23 AM EDT
prince raj66 reputationPosted Jun 11, 2014, 8:38 PM EDT
But i dont know how many and which shapes are in string.
so how can i check like operator with all them ?
VulpesRank #55 · 29.2K reputationPosted Jun 12, 2014, 12:57 AM EDT
//.....
Bhabani PrasadRank #8,369 · 223 reputationPosted Jun 12, 2014, 1:09 AM EDT
VulpesRank #55 · 29.2K reputationPosted Jun 12, 2014, 1:32 AM EDT
prince raj66 reputationPosted Jun 13, 2014, 5:13 AM EDT
this work on single selection, when more than two shape are selected its not return any row.
??????????
prince raj66 reputationPosted Jun 13, 2014, 5:35 AM EDT
http://www.c-sharpcorner.com/Forums/Thread/258515/two-string-in-where-condition-for-one-column.aspx
Thanks
VulpesRank #55 · 29.2K reputationPosted Jun 13, 2014, 6:01 AM EDT
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?