Jump to content


Sitewide Search - Requiring Multiple Tables

  • Please log in to reply
2 replies to this topic

#1 1internet

  • Members
  • PipPipPip
  • Advanced Member
  • 137 posts

Posted 27 November 2012 - 01:28 AM

I want to be able to search my entire site over all the tables, e.g. restaurants, entertainment, hotels, etc.
How is this done?
Also what if I wanted to search through more than one clolumn, e.g. title and body, and then further, what if I wanted to rank the ones that contained the search query in the title, ahead of the ones in the body?

#2 parkerj

  • Members
  • PipPipPip
  • Advanced Member
  • 189 posts
  • LocationBoston, MA
  • Age:39

Posted 27 November 2012 - 02:21 AM

To get you started, your query could start as

mysql_query( "SHOW TABLES FROM name_of_database" );

mysql_query( "SELECT * FROM information_schema.`COLUMNS` C WHERE TABLE_SCHEMA = 'YOUR_DATABASE'" );

#3 fenway

  • Staff Alumni
  • MySQL Si-Fu / PHP Resident Alien
  • 16,199 posts
  • LocationToronto, ON

Posted 30 November 2012 - 05:36 AM

You want a proper fulltext index -- MySQL isn't really good at that -- check out Sphinx.
Seriously... if people don't start reading this before posting, I'm going to consider not answering at all.

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users