I need to contruct a query, from keywords entered by a user in a text-field, which will do the following: Take the keywords and search in a table, after which car has all the given keywords.
My table looks like this:
field_id | car_id | keyword |
----------------------------
1 | 5 | 1989 |
-----------------------------
2 | 8 | old |
-----------------------------
3 | 8 | ford |
-----------------------------
4 | 2 | audi |
-----------------------------
5 | 5 | red |
-----------------------------
6 | 8 | cheap |
-----------------------------
Say if the user searched for “old”, “ford” and “cheap”, the car_id 8 should be returned because it contains all the keywords. How would you pull this off?
Assumes you know the number of key words entered and you want an a match on all of them
In addition it assumes that a keyword, car_id are unique. (car_Id 8 can’t have cheap twice)