I have a very poorly designed database i have inherited which i will be redesigning soon. However in the meantime i need to be able to create a query that searches this data correctly. I already know how to search it simply and i have a query that searches it but i would like to return more accurate results.
Ill start by explaining what i am working with. The SQL Column contains data in the following format:
Door Cat Car|Computer Paper Car|House Door Computer|
Where | is a delimiter between items (stored in a single field. Hmmm... ). There can be 0 to any number of items in the field each delimited by the |, in each row of the table. It's essentially a database within a database field...
My existing query searches this fine but say i searched for both Cat and Computer in the same query it would return the above row as a result as both words occur in the value. What i am looking to achieve is for it to only return the row above if both words occur between any of the delimited items in that value. Which in the above sample data, searching for Cat and Computer would not return this row as they do not appear together between the delimiters.
I know how messy this is, but its my only choice until i can completely overhaul this database. Does anyone know how i can create some kind of select query or some command that will help me to break this down, without me having to perform the regular query, split it by the delimiter,dump it into an array and then filter it further in my code?