You can use this technique given below:
SELECT * FROM Tags
WHERE '|ruby|scruffy|rails|rubyonrails|'
LIKE '%|' + name + '|%'
Want to learn SQL from basics! Here's the right video for you on SQL provided by Intellipaat:
So, here's the C# code you can refer to:
string[] tags = new string[] {"rails", "ruby", "scruffy", "rubyonrails" };
const string cmdText = "select * from tags where '|' + @tags1 + '|' like '%|' + name + '|%'";
using (SqlCommand cmd1 = new SqlCommand(cmdText)) {
cmd1.Parameters.AddWithValue("@tags", string.Join("|", tags1);
}
Disadvantages are as follows:
LIKE "%...%" queries are not indexed. So, the performance is poor. Make sure you don't have any blank, | or null tags otherwise it won't work.