Wrox Home  
Search P2P Archive for: Go

  Return to Index  

sql_language thread: Joining the same table twice


Message #1 by ibooth@t... on Thu, 31 May 2001 16:33:19
I am writing an asp script that contains a data access object.
I have a table that holds site names and company names (not my design!) 
called TEST_GSN.
I need to list certain sites sorted in company, site number order.
Access 2000 has come up with an sql statement of:

SELECT TEST_GSN_1.SITE_DESC, TEST_GCI.SITE_NO, TEST_GSN.SITE_DESC FROM 
(TEST_GCI INNER JOIN TEST_GSN ON TEST_GCI.SITE_NO = TEST_GSN.SITE_NO) 
INNER JOIN TEST_GSN AS TEST_GSN_1 ON TEST_GSN.DEPT_CODE = 
TEST_GSN_1.SITE_NO WHERE (((TEST_GSN_1.COMPANY_NO)='CL') AND 
((TEST_GCI.ACT_COMPLETE) Is Null) AND ((TEST_GCI.COMPANY_NO)='CL') AND 
((TEST_GSN.LEDGER_TYPE_CNP)='COS') AND ((TEST_GSN.COMPANY_NO)='CL') AND 
((TEST_GSN_1.LEDGER_TYPE_CNP)='NOM')) ORDER BY TEST_GSN_1.SITE_DESC, 
TEST_GCI.SITE_NO;

I'm running MS Windows 2000 Server with IIS 5.0.

When I try and browse this page I get the error:

Error Type:
Microsoft OLE DB Provider for ODBC Drivers (0x80004005)
Easysoft Error: Table name expected
/Companies/TCL/Contracts/ContractSelection.asp, line 18

line 18 is "set rs=objcommand.execute" so I'm guessing the error is in the 
sql command.

I've only been writing asp scripts for a week so please don't be too 
technical with any solutions.

  Return to Index