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!

Query SQL 2000 1

Status
Not open for further replies.

phil34

MIS
Apr 8, 2004
30
GB
Can any one help me pleeas? probably basic for you but I testing the inner join query and get syntax error with inner. Can any one help? correspondence in main table with primary and foreign key


select *
From correspondence, contact, corressubject
Inner Join corressubject on correspondence.contactid = corressubject.corresid
Inner Join contact on correspondence.ccorresid = contact.contactid

Also tried
select *
From correspondence, contact, corressubject
Inner Join correspondence.contactid on corressubject.corresid
Inner Join correspondence.corresid on contact.contactid
 
The syntax for JOINs is:

SELECT column names
FROM first table
INNER JOIN second table
ON first table.column = second table.column
INNER JOIN third table
ON second table.column = third table.column

Refer to the BOL for more information on JOINs.

-SQLBill

BOL=Books OnLine=Microsoft SQL Server's HELP
Installed as part of the Client Tools
Found at Start>Programs>Microsoft SQL Server>Books OnLine

Posting advice: FAQ481-4875
 
After running the query the table lables appear but no data i.e

Name Surname Address
No Data No Data No Data

SELECT *
FROM correspondence
INNER JOIN contact
ON correspondence.contactid = contact.contactid
INNER JOIN corressubject
ON contact.contactid = corressubject.corresid
 
phil34,

That would suggest that there are no records where the contactid and corresid's are identical and present in each table. You could try turning your INNER JOINS to LEFT JOINS, then see what you get.

mrees
 
Mrees thanks the left join has worked.
Silly questions is the left join producing the same data as the inner join?
 
No left joins do not do what inner joins do. Please go to tBooks ONline and read about the various types of joins and come back if you have any questions.

Questions about posting. See faq183-874
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top