Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Problems with basic Join

Status
Not open for further replies.
May 22, 2002
63
GB
Can anyone help me with this query:

SELECT company.companyName, myaccounts.activelead FROM company,myaccounts where (company.companyName like "%cousins%") or (myaccounts.accountName like "%cousins%")
ORDER BY company.companyName Asc

There will always be a companyName stored in I would like it to return from the LIKE query, but not always one in the activelead table.

At the moment, if there is no entry like "cousins" in the myaccounts table, i get no returned results even though there are matching entries in companyName.

Can anyone help me?
 
Anders

You are selecting records from two tables, without giving a statement about how to link the two tables.

Try something like this ( I am guessing which fields link the two tables):

SELECT company.companyName, myaccounts.activelead
FROM company,myaccounts
WHERE

company.Ref = myaccounts.companyRef
and
(

(company.companyName like "%cousins%") or (myaccounts.accountName like "%cousins%")

)
ORDER BY company.companyName Asc
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top