The forums have permanently moved to This forum will be kept around in read-only mode for archival purposes. To learn how to continue using your existing account on the new forums, check out this thread.

Results 1 to 2 of 2

Thread: Searching and querying an entire database

  1. #1

    Searching and querying an entire database

    Hi everyone! I tried a search on this topic in the forums to prevent double-posting but I couldn't find a post nor a solution.

    What I do know
    I'm fairly familiar with MySQL databases in that I know how to use phpMyAdmin. I know how to pull data from a database and display.

    What I don't know
    I don't know how to create a working search function that does the following:
    - Search all the columns within the tables within the database and displays the results

    For example, I have a database called "french_destination" with about 8 tables, those tables are:

    - accommodations
    - sports
    - towns
    - restaurants
    - beaches
    - parks
    - villas
    - agencies

    If a user searched for "colonial" it should search all the columns within those 8 tables and then display all the matching results.

    I'd like to know if this was possible?

    My search form:

    PHP Code:
    <form method="post" action="search.php">
    input type="text" name="search" size=25 maxlength=25>
    input type="Submit" name="Submit" value="Submit">
    This is what I had that only searched a certain table and a certain column: The problem though was that it only searched a certain table and certain column. I need it to search ALL columns within ALL tables and display ALL matching results.

    PHP Code:
    mysql_connect ("localhost""french_user","french123")  or die (mysql_error());
    mysql_select_db ("french_destination");

    $search $_POST['search'];

    $result mysql_query("SELECT * FROM accommodations WHERE caption LIKE '%$search%'");

    while (
    $row mysql_fetch_array($result)){
    'ID: '.$row['accommodations_name'];

    I researched online and the only things that were semi-useful (but I couldn't grasp them fully) were:

    Using UNION (I already know OR)
    Using show_tables and then querying results from the show_tables results

    Any help would be greatly appreciated!

  2. #2
    MySQL's "LIKE" is not meant for search engines. There's a technique called Full-Text Search ( ) that can actually sort your searches by relavence. I don't know what algorithm it uses - probably not as good as Google's - but it's way better than LIKE; there's no doubt about that.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Home About Meet the Moderators Advertise

 Link to Us


Copyright 1999 - 2012