SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Enthusiast
    Join Date
    Dec 2008
    Posts
    47
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    mysql sum different field derived from different tables

    hi to all

    In my search I used autosuggest. The problem now is I have to search the value in multiple fields such as firstname,middlename,lastname,caption etc. How to identify that the match string will belong on specific field name.

    let say i have table

    firstname middlename lastname caption
    james kelly tow handsome
    timy john fung fearless
    hanes bing ken great

    in my input field once I typed "j" I should select and ouput

    james
    john
    great

    Currently I just output the firstname so instead of the above result I came out like below which is not good.

    james
    timy
    hanes


    It is possible? Any help would greatly appreciated.

  2. #2
    Follow Me On Twitter: @djg gold trophysilver trophybronze trophy Dan Grossman's Avatar
    Join Date
    Aug 2000
    Location
    Philadephia, PA
    Posts
    20,580
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Change your database query.

    Instead of "SELECT ... FROM table WHERE firstname LIKE 'j%'" check all the columns

    SELECT ... FROM table WHERE firstname LIKE 'j%' OR middlename LIKE 'j%' OR lastname LIKE 'j%'


Bookmarks

Posting Permissions

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