#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Apr 2002
    Posts
    5
    Rep Power
    0

    Querying multiple columns


    Hi All,

    I'm working on this job board system and having trouble with the search facility.

    In a table each job listed one vacancy per row. There is about 25 columns in the row like: job description, job title, skills required, location, job id, ... I'm trying to make search that will search about in 8 columns. So far I have managed to search only from two columns. My query string:

    SELECT * FROM jobs WHERE jobdesc OR position LIKE '%".$q."%' ORDER BY id_internal DESC

    Attempts to add more columns ware unsuccessful.

    Any ideas ?


    Cheers
    Max
  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
    23
    You can't write a query like that.

    Basically you are saying "where jobdesc (is true) OR position like '%$q%'" which isn't what you really want is it?

    You are trying to say:

    where jobdesc like '%$q%' OR position like '%$q%'

    You'd have to write that for EACH field you want to compare %$q% to.

    You might want to check out using a fulltext index for doing this type of search.
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Apr 2002
    Posts
    5
    Rep Power
    0
    Thanks rod k, it works

    Maxr

IMN logo majestic logo threadwatch logo seochat tools logo