Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    Regular Coder
    Join Date
    Sep 2006
    Posts
    216
    Thanks
    9
    Thanked 0 Times in 0 Posts

    SQL query JOIN and LIKE clause

    Hello,

    I need to run a query which uses a like query like the one below, no problem:

    Code:
    SELECT * FROM footballers WHERE sname LIKE '%$criteria%'
    however, if I want to join two tables and still use the LIKE clause how would the syntax look??

    My guess below was incorrect. any help would be appreciated. thank you

    Code:
    WHERE sname LIKE '%$criteria%' AND (footballers.footballerID = PremTeams.footballerID)

  • #2
    UE Antagonizer Fumigator's Avatar
    Join Date
    Dec 2005
    Location
    Utah, USA, Northwestern hemisphere, Earth, Solar System, Milky Way Galaxy, Alpha Quadrant
    Posts
    7,691
    Thanks
    42
    Thanked 637 Times in 625 Posts
    That syntax works fine for me...

    What error are you getting?

  • #3
    Super Moderator guelphdad's Avatar
    Join Date
    Mar 2006
    Location
    St. Catharines, Ontario Canada
    Posts
    2,633
    Thanks
    4
    Thanked 148 Times in 139 Posts
    show us your entire query instead of some of it. for instance if you parsed the second bit above to the first bit you would get an error because you dont have the first table named.

  • #4
    Regular Coder
    Join Date
    Sep 2006
    Posts
    216
    Thanks
    9
    Thanked 0 Times in 0 Posts
    O got it working now thanks, stupid error, it was a typo. thanks anyway


  •  

    Posting Permissions

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