I have a string array that gets split at the comma,
string example = "happy,sad,depressed,shock";
string[] split = example.Split(',');
What i want to do is check if there is only one string lets say happy,and just have that one string populated in my where statement. But if there is more than one string in the array i want to pass one of them to one WHERE Statement then the others to a built up OR
if (split.Count() == 1)
{
query = query + "WHERE emotion LIKE '%" + split[0] + "%'";
}
else
{
query = query + "WHERE emotion LIKE '%" + split[0] + "%'";
for (int i = 0; x < split.Length; i++)
{
query = query + "OR emotion LIKE '%" + split[i] + "%'";
}
}
so my query will end up like:
WHERE emotion LIKE %happy% OR LIKE %sad% OR LIKE %depressed%
Not quite sure how to structure the syntax for that. Any help will be greatly appreciated.