?
Solved

SQL Syntax error (finding common records in two tables) using VB6

Posted on 2007-10-10
2
Medium Priority
?
207 Views
Last Modified: 2010-03-20
Dear Gurus
I have two tables, and want to use VB6 to list those records where the contents of the COMPANY_NAME field is common to both tables. I've tried the following, but Microsoft says error.
SQLStr = "SELECT FROM DB_ALL_2.COMPANY_NAME " & _
"FROM DB_ALL_2 LEFT JOIN DB_ALL_1 ON DB_ALL_2.COMPANY_NAME = DB_ALL_1.COMPANY_NAME " & _
 "WHERE (DB_ALL_1.COMPANY_NAME = DB_ALL_2.COMPANY_NAME)"
           Recordset1.Open SQLStr, DbsConnection, adOpenStatic

Microsoft's error is:
'The SELECT statement includes a reserved word or an argument name that is misspelled or missing, or the punctuation is incorrect'
0
Comment
Question by:BrianBeck
2 Comments
 
LVL 143

Accepted Solution

by:
Guy Hengel [angelIII / a3] earned 1000 total points
ID: 20048217
you use SELECT FROM , so you included no columns to be returned.

at least 1 column needs to be specified
SQLStr = "SELECT DB_ALL_2.COMPANY_NAME FROM DB_ALL_2.COMPANY_NAME " & _
"FROM DB_ALL_2 LEFT JOIN DB_ALL_1 ON DB_ALL_2.COMPANY_NAME = DB_ALL_1.COMPANY_NAME " & _
 "WHERE (DB_ALL_1.COMPANY_NAME = DB_ALL_2.COMPANY_NAME)"
0
 

Author Comment

by:BrianBeck
ID: 20048248
Thanks angelIII !
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Composite queries are used to retrieve the results from joining multiple queries after applying any filters. UNION, INTERSECT, MINUS, and UNION ALL are some of the operators used to get certain desired results.​
Recursive SQL is one of the most fascinating and powerful and yet dangerous feature offered in many modern databases today using a Common Table Expression (CTE) first introduced in the ANSI SQL 99 standard. The first implementations of CTE began ap…
In a question here at Experts Exchange (https://www.experts-exchange.com/questions/29062564/Adobe-acrobat-reader-DC.html), a member asked how to create a signature in Adobe Acrobat Reader DC (the free Reader product, not the paid, full Acrobat produ…
With just a little bit of  SQL and VBA, many doors open to cool things like synchronize a list box to display data relevant to other information on a form.  If you have never written code or looked at an SQL statement before, no problem! ...  give i…

864 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question