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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

SQL Join query ? 1

Status
Not open for further replies.

44nato44

Programmer
Dec 12, 2008
115
NL
Hi

I am not sure how I can formulate this the best way, but I think I need to make a join query which I have never done before.

I got two tables tblProjects and tblCompany

I got an Ajax script which looks in the database for each letter which is typed into a search field for the company name.

In tblProjects I got a companyID field which will need to match an ID field in the tblCompany. The search field need to search in tblcompany.CompanyName for each letter typed in.

The below line does not work but I hope it gives an idea what I want to do :

SQLProjects = "SELECT tblProjects FROM tblProjects WHERE CompanyID = '" & Session("CompanyID") & "' AND tblCompany.CompanyName LIKE '" & right(request.querystring("q"),len(request.querystring("q"))-2) & "%' ORDER BY tblProjects.ProjectName
 
The query you are looking for is probably very similar to this:


Select tblProjects.*
from tblPRojects inner join tblcompany
On tblProjects.companyid = tblCompany.companyid
where tblCompany.companyName like 'ab%'

-George

"The great things about standards is that there are so many to choose from." - Fortune Cookie Wisdom
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top