If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > Visual Basic > VBScript / help needed with query

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old
Registered User
 
Join Date: Jan 2013
Posts: 2
VBScript / help needed with query

Hi!
I'm trying to build a query that will access three tables and I want to run this query via VBscript.

This is my working version:
Code:
sSQL = "SELECT OPNPOS.FUND, SECRTY.TKR, SECRTY.ISIN, OPNPOS.QTY, OPNPOS.LCL_ACCINC, PRIHST.PRICE / SECRTY.FACTOR AS CENA 
FROM OPNPOS INNER JOIN (SECRTY INNER JOIN PRIHST ON SECRTY.TKR = PRIHST.TKR) ON OPNPOS.TKR = SECRTY.TKR 
WHERE OPNPOS.FUND IN " & sFUND & " AND PRIHST.PRCDATE = #" & sDATA & "# 
ORDER BY OPNPOS.FUND"
I need to change this query in order to see every element from OPNPOS table so I would change
Code:
FROM OPNPOS INNER JOIN
to
Code:
FROM OPNPOS LEFT JOIN
but it gives me an error.

I know that there are some ways to workaround this but I've tried a lot of combinations and get no success ;/

Anyone can help me?
Reply With Quote
  #2 (permalink)  
Old
Resident Curmudgeon
 
Join Date: Feb 2004
Location: In front of the computer
Posts: 14,741
I'm actually rather surprised that the code you posted will run "as is" but what you need is probably:
Code:
sSQL = "SELECT OPNPOS.FUND, SECRTY.TKR, SECRTY.ISIN, OPNPOS.QTY, OPNPOS.LCL_ACCINC
, PRIHST.PRICE / SECRTY.FACTOR AS CENA FROM OPNPOS LEFT JOIN SECRTY ON 
OPNPOS.TKR = SECRTY.TKR INNER JOIN PRIHST ON SECRTY.TKR = PRIHST.TKR
WHERE OPNPOS.FUND IN " & sFUND & " AND PRIHST.PRCDATE = #" & sDATA & "# 
ORDER BY OPNPOS.FUND"
-PatP
__________________
In theory, theory and practice are identical. In practice, theory and practice are unrelated.
Reply With Quote
  #3 (permalink)  
Old
Registered User
 
Join Date: Jan 2013
Posts: 2
Thanks for answer. It doesn't work. I have attached error message.
Attached Thumbnails
VBScript / help needed with query-error.jpg  
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On