• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 209
  • Last Modified:

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

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
BrianBeck
Asked:
BrianBeck
1 Solution
 
Guy Hengel [angelIII / a3]Billing EngineerCommented:
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
 
BrianBeckAuthor Commented:
Thanks angelIII !
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Cloud Class® Course: Microsoft Windows 7 Basic

This introductory course to Windows 7 environment will teach you about working with the Windows operating system. You will learn about basic functions including start menu; the desktop; managing files, folders, and libraries.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now