#1
  1. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2000
    Posts
    1
    Rep Power
    0
    Hello,

    Is it possible to search in multiple columns (in one table or even better the whole database) for a string pattern, without specifying al the columnnames?

    Regards,

    Daan
  2. #2
  3. No Profile Picture
    Apprentice Deity
    Devshed Loyal (3000 - 3499 posts)

    Join Date
    Jul 1999
    Location
    Niagara Falls (On the wrong side of the gorge)
    Posts
    3,237
    Rep Power
    18
    Nope.
  4. #3
  5. Banned (not really)
    Devshed Supreme Being (6500+ posts)

    Join Date
    Dec 1999
    Location
    Brussels, Belgium
    Posts
    14,640
    Rep Power
    4476
    Well, you kind of can, but I don't think it's a very good way to do it. You should think about re-organizing your database to make searching better.

    SELECT * FROM your_table WHERE CONCAT(column1,column2,column3...) like '%$your_variable%';

    It basically takes the columns and joins them together in one string, then searches for your variable. The % signs mean your string can be preceded and followed by anything.

    An option I'd recommend is to write another script that searches your table columns and extracts all the words, then stores the words in another table with an ID back to the record it came out of. Then you do your searches on this table, return the IDs that match the word, and look up those IDs in your main table. You can index this second table to make searches pretty fast.

    My $0.02.

    ---John Holmes...

    ------------------
    *************************************************************
    * The manual can probably answer 90% of your questions... *
    * *
    * PHP Manual. www.php.net/manual *
    * MySQL Manual: www.mysql.com/documentation/mysql/bychapter *
    *************************************************************

Similar Threads

  1. using multiple columns in one index
    By bakedbean in forum MySQL Help
    Replies: 3
    Last Post: November 6th, 2003, 09:30 AM
  2. Summing columns from multiple tables then sorting
    By PeMo in forum PHP Development
    Replies: 9
    Last Post: October 25th, 2003, 11:47 PM
  3. Displaying database records over multiple columns
    By SnowCrash in forum PHP Development
    Replies: 4
    Last Post: September 25th, 2003, 06:50 AM
  4. Help with pattern matching in drop down menu
    By pic in forum PHP Development
    Replies: 3
    Last Post: August 24th, 2003, 04:57 PM
  5. Replies: 2
    Last Post: August 10th, 2003, 04:42 PM

IMN logo majestic logo threadwatch logo seochat tools logo