Results 1 to 2 of 2
Thread: which keywords found from search
May 8, 2005, 22:52 #1
- Join Date
- May 2005
- 0 Post(s)
- 0 Thread(s)
which keywords found from search
not sure how to put it, but let say that I enter a phrase of 4 key words (eg: apple orange banana pine)to search on a column 'text' of a table:
$query = "SELECT text FROM books WHERE text ='apple' OR text='orange' OR text='banana' OR text='pine'";
If we search 1 key word at a time, that can do, but in this case, i have have than 1 phrase to begin with; thus search 1 keyword at a time sounds not a good idea, but not sure if there is any better alternative.
May 8, 2005, 23:58 #2
I'm not sure I totally understand, but I think you need to add in a search for your primary key, substituting in the primary key column name of course. You might also like to use 'IN' to clean up your code a bit.
$query = "SELECT primary_key, text FROM books WHERE text IN ('apple','orange','banana','pine');