Hey guys, i need a real quick help with something with my db-table Well i have a table called meta This meta table consists of the the following columns ID meta_key meta_value ---------- Well what i need to do is simple i need to get all meta ids that it's meta_key = status & name and at the same time i need to check if the meta_value = active & %the name% for more details in words: i have an advanced search and the user may search for the data where the status = 'active' And also the name LIKE '%the search%' I hope now all people understand my problem. please guys help me Thanks a lot in advance
Is this you were looking for? SELECT * FROM meta WHERE (meta_key = 'status' AND meta_value = 'active') OR (meta_key = 'name' AND meta_value LIKE '%the name%') Code (markup):
Well it's a little bit near, but the problem is that in your query, you are saying if you found any meta_key = status and meta_value = 'active' get them if you didn't found any results with that just get the meta_key = 'name' AND meta_value LIKE '%the name%' i don't want it to check if that there get otherwise get the second one, no i want it to look for both to get me all the rows that it's meta_key = status and name ,,, and all rows that is meta_value = active and LIKE '%the name%'. sorry thats not what i need do you have any other suggestions in your mind.
Well, I've got the idea of the meta from wordpress. it make things much cooler, i mean instead of doing it with a looooot of columns at one place you can do it with meta meaning that you can have the id referring to the item and the meta_key and meta_value, but my script will have an advanced search it will be like the user can select more than one item to get his desired content. like --------------------------- search: Status: will be select box name: will be input --------------------------- if you where were me and you have this meta thing in the database, how would you write your query to get the right result?