Sql statement problem

I need to write a sql statement that will retrieve records from one table and add a boolean field if the record customerid exists in a second table.  Example:
Table1 fields     CustomerID,CustomerName       Table 2 field   CustomerID

I want the sql statement to be something like:  
Select table1.CustomerID, table1.CustomerName, table1.IsInTable2
From Customer InnerJoin Table2 on table2.CustomerID

Thats pretty much guess work on my part but I hope it conveys enough information.
                                       
 
LVL 2
Moe DeShongAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Guy Hengel [angelIII / a3]Billing EngineerCommented:
close:
Select table1.CustomerID, table1.CustomerName, case when table2.CustomerID IS NULL then 0 else 1 end IsinTable2
From Customer left Join Table2 on table2.CustomerID

Open in new window

Moe DeShongAuthor Commented:
Here's the way I input but it gives an error

            cSql = "SELECT *, CASE when ContractInformation.txtCustomerID IS NULL then 0 else 1 END HasContract " _
              & "FROM Customers LEFT JOIN ContractInformation ON ContractInformation.txtCustomerID  " _
              & "ORDER BY datInputDate Desc"
Guy Hengel [angelIII / a3]Billing EngineerCommented:
what error?
Big Business Goals? Which KPIs Will Help You

The most successful MSPs rely on metrics – known as key performance indicators (KPIs) – for making informed decisions that help their businesses thrive, rather than just survive. This eBook provides an overview of the most important KPIs used by top MSPs.

SharathData EngineerCommented:
check this:
  cSql = "SELECT C.*, CASE when I.txtCustomerID IS NULL then 0 else 1 END HasContract " _
              & "FROM Customers C LEFT JOIN ContractInformation I ON C.CustomerID = I.txtCustomerID  "  
Moe DeShongAuthor Commented:
The error is "EerrorInfo.getdescription failed"   Error code -2147467259

I am using an MS Access backend if that makes a difference.
Guy Hengel [angelIII / a3]Billing EngineerCommented:
ok, please try this alternative:
Select table1.CustomerID, table1.CustomerName, IIF(ISNULL(table2.CustomerID),0,1) IsinTable2
From Customer left Join Table2 on table2.CustomerID

Open in new window

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Moe DeShongAuthor Commented:
Perfect.  Glad to see someone else is working on Saturday.   Thanks
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic.NET

From novice to tech pro — start learning today.