DBQuery with Join

Technical support and scripting issues

Moderators: Dorian (MJT support), JRL

Post Reply
JR_Tapper
Newbie
Posts: 2
Joined: Thu Jun 22, 2023 7:47 pm

DBQuery with Join

Post by JR_Tapper » Thu Jun 22, 2023 8:01 pm

This seems to be pretty trivial, but I can't make MS work with a query with a JOIN in it.

I have searched the forum and the docs, and I have not found anything that refers to this scenario. My script has a couple of SQL queries using DBQUERY. The first works just fine and returns records. The second will only return any records after I remove the JOIN clause.

It is a very simple query in the form of;
SELECT a.field1 b.field2 FROM table1 a JOIN table2 b ON a.field1 = b.field1 WHERE {some conditions}
I also tried;
SELECT a.field1 b.field2 FROM table1 a, table2 b WHERE a.field1 = b.field1 AND {some conditions}
I have tested both queries directly in SQL and they both work as expected.

I don't get any errors when MS runs the DBQuery line, but I never get any records either.

I could write into the code a loop to duplicate this output, but that seems like is very inefficient and I assume that MS should be able to handle this basic SQL structure.

Any advice or suggestions are welcome.
Thanks!

User avatar
Dorian (MJT support)
Automation Wizard
Posts: 1354
Joined: Sun Nov 03, 2002 3:19 am
Contact:

Re: DBQuery with Join

Post by Dorian (MJT support) » Thu Jun 22, 2023 11:04 pm

Can you post the pertinent lines of your script please?
Yes, we have a Custom Scripting Service. Message me or go here

JR_Tapper
Newbie
Posts: 2
Joined: Thu Jun 22, 2023 7:47 pm

Re: DBQuery with Join

Post by JR_Tapper » Fri Jun 23, 2023 1:35 am

Thanks Dorian,

I found the issue, it was a typo in my SQL code that my SQL program overlooked.

User avatar
Dorian (MJT support)
Automation Wizard
Posts: 1354
Joined: Sun Nov 03, 2002 3:19 am
Contact:

Re: DBQuery with Join

Post by Dorian (MJT support) » Fri Jun 23, 2023 6:55 am

Aah, excellent!
Yes, we have a Custom Scripting Service. Message me or go here

Post Reply
cron
Sign up to our newsletter for free automation tips, tricks & discounts