table ad:
id uid name description
1 1 BMW Z5 good condition
2 1 Sell house new
table ad_values
id sid m_input m_value
1 1 car BMW
2 1 year 2010
3 1 category 1
4 2 year 2005
How can I search in table ‘ad_values’? For example I need car BMW which build year is 2010. I tried something like this:
SELECT * FROM ad_values
WHERE (m_value='BMW' AND m_input='car') AND (m_input='year' AND m_value='2010') AND (m_input='category' AND m_value='1')
GROUP BY sid
Then I get SID and SELECT from table ‘ad’. But it doesn’t work.
It seems like you want the results to come from table ‘ad’ after providing search query terms for table ‘ad_values’. Is this something like what you want?
UPDATE
I fixed the query to correctly return matching records.
This query should yield the following results:
id uid name description
1 1 BMW Z5 good condition
Sound about right?