Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Easy VB SQL Question

Posted on 2000-03-08
7
Medium Priority
?
184 Views
Last Modified: 2010-05-02
I am trying use an SQL statement within VB 6.0 to query against two different tables that have the same field names.  Here is what I have tried that does not work:

SELECT DISTINCT [Trustee Num], [Trustee Num] FROM [BkrpRcon], [BkrpList] ORDER BY [Trustee Num]

I'm no SQL expert so I have no idea what else to try.  Thanks in advance for any advice.
0
Comment
Question by:jasonboetcher
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
7 Comments
 
LVL 1

Expert Comment

by:nunya
ID: 2597668
SELECT DISTINCT [BkrpRcon].[Trustee Num], [BkrpList].[Trustee Num] FROM [BkrpRcon], [BkrpList] ORDER BY [BkrpList].[Trustee Num]

fully qualify your fields.

good luck.
0
 

Author Comment

by:jasonboetcher
ID: 2597737
I changed my SQl statement to the following:

strSQL = "SELECT DISTINCT [BkrpRcon].[Trustee Num], [BkrpList].[Trustee Num] FROM [BkrpRcon], [BkrpList] ORDER BY [BkrpRcon].[Trustee Num]"

It doesn't abend now but it makes the application hang up.  I'm using the SQL statement as the Recordsource property of an Adodc that is eventually used to populate a combo box.  Any idea why this is causing the application to hang?
0
 
LVL 70

Expert Comment

by:Éric Moreau
ID: 2598760
The query you just build is a cross join query. What it means is if you have 1000 rows in the first table and 1000 rows in the second table, the recordset generated by the query will contain 1000*1000=1 000 000 records. This can be a reason for your app to hang.

What do you want to see in your combo?
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
LVL 14

Expert Comment

by:wsh2
ID: 2598882
Hi emoreau.. <smile>

I was looking at those SQL statements scratching my head as well.. but as I am not an SQL expert.. <and naturally timid and shy.. blush.. blush>.. was afraid to comment. Nevertheless.. it did bring a question to mind.. how could one build a Distinct to Distinct relationship between two files? Oh well.. off to the research books for me.. Nice yacking at ya.. <smile>.
0
 

Author Comment

by:jasonboetcher
ID: 2600336
I need to populate the combo box with distinct trustee numbers from two different tables.  The user of the application uses this combo box to delete all records containing this trustee number throughout the system.  The way it is set up now, the combo box only populates with unique trustee numbers from the BkrpRcon table, so if they need to delete a trustee that is unique to the BkrpList table they cannot.  I thought I might be able to create two seperate ado recordsets, combine them, then sort them but I'm not clear on how or if this would be the way to do it.
0
 
LVL 70

Accepted Solution

by:
Éric Moreau earned 40 total points
ID: 2600582
Try this query:

SELECT distinct [trustee num]
FROM bkrpcon
union
SELECT distinct [trustee num]
FROM bkrplist
order by [trustee num]
0
 

Author Comment

by:jasonboetcher
ID: 2600626
That worked perfectly.  Thank you very much!!
0

Featured Post

Technology Partners: 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

Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Suggested Courses

721 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