Pascale Lunal wrote: > Oops: sorry if this message appears twice but my connection broke down > just when I clicked 'send'. > > Hello, > > I am currently writing a search query in PHP to: > > 1. search in MySQL database (not in one table but in all the tables of > the whole database), > > 2. search when more than one searchterm is entered (it works for 1 > search term but not for more). > > My questions related to the above two points are: > > 1. How do I modify the following line (basically how to change "mytable" > to "allmytable") so that all the tables are searched (each table has > exactly the same structure) wihtout having to type every single table > name (since I have 50 of them !) ? > > $query = "SELECT * FROM mytable WHERE columnname LIKE '%$searchterm%'"; > Since all your tables have the same structure, you can create a "merge table" and run your select on it.
> 2. The search is performed by typing the word to be searched. This works > for 1 word but not if I enter more than 1 term. How can I make a > multiple word search ? You should split your $searchterm in multiple words and build a query that looks like: SELECT * FROM mytable WHERE columnname LIKE '%$word1%' AND columnname LIKE '%$word2%'... (Sorry for not beeing more specific but it is a PHP, not MySQL, problem and I have no experience in PHP). > > Any help, example scripts, tutorials would be greatly appreciated. > > Best regards, > > Pascale > Regards -- Joseph Bueno --------------------------------------------------------------------- Before posting, please check: http://www.mysql.com/manual.php (the manual) http://lists.mysql.com/ (the list archive) To request this thread, e-mail <[EMAIL PROTECTED]> To unsubscribe, e-mail <[EMAIL PROTECTED]> Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php