I have a database in which I have few tables. I have a table which contains a column containing tag names and tag IDs. There is a situation where I have tag name and I want the tag IDs for all those tags whose tag names start with the input text.
The problem is that when I am hitting database for tag name "%", it is returning all the rows of that table. But I need only those rows which contains tag names starting with the the input text (which in this case is starting with the "%" symbol).
Example:
TagName
-------
abc
%test_tag
def
the result should be "%test_tag" if I search for "%".
Currently, the query which I am using is
SELECT * FROM Tags WHERE TagName like '"+tagName+" %'
How to fix it?