Jump to content

[SOLVED] Search multiple DB fields


Recommended Posts

I have a small problem that should be simple to fix, I am programming my site with dreamweaver since I don't know programming lang. yet. I am building a search results page and since I don't know php I am having trouble with the where statement, all I want is to search 5 0r 6 fields in the same table for the url variable. if someone could help me with what I am suppose to put in the where, in dreamweaver I would greatly appreciate it. Thank You

Link to comment
https://forums.phpfreaks.com/topic/87161-solved-search-multiple-db-fields/
Share on other sites

SELECT

          *

  FROM

          table_name

WHERE

                col1 = 'something'

          OR col2 = 'something'

          OR col3 = 'something'

          OR col4 = 'something'

          OR col5 = 'something'

 

 

MySQL select syntax page:

 

http://dev.mysql.com/doc/refman/5.0/en/select.html

 

With the "OR" only one of the columns needs to match the "something" in order to return the row. A returned row could have had a match on more than one column. Keep in mind that with the "=" it must be an exact match. Otherwise you must use "LIKE" instead of "=" or create a fulltext index across the columns.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.