advance query to database

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
cade
Forum Commoner
Posts: 55
Joined: Tue Jul 03, 2007 8:18 pm

advance query to database

Post by cade »

I have a form where one text and one button displayed to perform searching in my database. I want to perform searching not just based on the phrase provided by user but also like to perform search for every single word provided by user.

How do i implement this if my user enter query such as this: "mp3, flv, mp4". Usually, in my database, query will be made to a field that match phrase like this "mp3, flv, mp4". Now i want to enhance it by enable searching to a field that match word "mp3" or "flv" or "mp4". When I perform this using "OR" operator, the result have redundance and repeated data. Can someone show me the exact way. If you can show how google return data, would be appreciated :D
User avatar
Christopher
Site Administrator
Posts: 13596
Joined: Wed Aug 25, 2004 7:54 pm
Location: New York, NY, US

Re: advance query to database

Post by Christopher »

You could do something like "WHERE RIGHT(filename, 3) IN ('mp3', 'mp4', 'flv')".
(#10850)
Post Reply