jasonboetcher
asked on
Easy VB SQL Question
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.
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.
ASKER
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?
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?
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?
What do you want to see in your combo?
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>.
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>.
ASKER
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.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
That worked perfectly. Thank you very much!!
fully qualify your fields.
good luck.