AnsweredAssumed Answered

SQL with multiple tables

Question asked by deathrobot on Apr 4, 2014
Latest reply on Apr 5, 2014 by deathrobot

Title

SQL with multiple tables

Post

     Having some conceptual trouble here. I've got this SQL statement which so far works fine. I can type in a search term and it will check in People.name, People.emailAddress, and Company.name:

     ExecuteSQL(
     "SELECT
     People.name
      
     FROM
     People
      
     LEFT JOIN
     Companies ON People.id_Company = Companies.id
      
     WHERE 
     (
     LOWER(People.name) LIKE '%SEARCHTERM%'
     )
     OR
     (
     LOWER(Companies.name) LIKE '%SEARCHTERM%'
     )
     OR
     (
     LOWER(People.emailAddress1) LIKE '%SEARCHTERM%'
     )
     "; ""; "" )
      
     I would also like to check another table that is related to People via a join table:
      
     People ->Played<-Instruments
      
     I'd like to be able to include instruments from the Instruments table when they are related to the person via the Played table. Confused as to how to add this to my current SQL query.
      
     Thanks for any help!
     Michael

Outcomes