anders2002
MIS
Hi,
I've got a problem with a search I am trying to perform in MySQL:
I have a company table and a contacts table. They are linked by a table called contactassocs which simply assigns an ID to an entry where the companyId and contactID and entered. This is the assocID.
I want to do a 'like' search so users of a system I am coding can simply search all fields and return entries that match within the contacts database system.
However the problem I have is where a company has been setup and no contacts added to it - hence no relationship established in the contactassocs table the SQL that specifies the joins between tables returns no results - even if company fields do match the search.
Short of writing a complex PHP script to do loads of different iterations of the SQL query, is there a single sql query I can write that will satisfy an output if there is a match in either the company OR contacts table, even if I explain the join within the sql?
Cheers,
Anders
I've got a problem with a search I am trying to perform in MySQL:
I have a company table and a contacts table. They are linked by a table called contactassocs which simply assigns an ID to an entry where the companyId and contactID and entered. This is the assocID.
I want to do a 'like' search so users of a system I am coding can simply search all fields and return entries that match within the contacts database system.
However the problem I have is where a company has been setup and no contacts added to it - hence no relationship established in the contactassocs table the SQL that specifies the joins between tables returns no results - even if company fields do match the search.
Short of writing a complex PHP script to do loads of different iterations of the SQL query, is there a single sql query I can write that will satisfy an output if there is a match in either the company OR contacts table, even if I explain the join within the sql?
Cheers,
Anders