|
-
Aug 24th, 2004, 01:25 PM
#1
Thread Starter
Hyperactive Member
Merge Columns or Recordsets ?? [VB6]
Given two SQL Tables [Client and Group], each table has 1 column (to simply things), a form [Frm], and a ComboBox [cb].
For the SQL Tables:
- Client has a column called CUSTOMER
- Group has a column called GROUPNAME
What I need is to display all values in column CUSTOMER (from Table Client) and GROUPNAME (from Table Group) in the Combobox as one column of choices.
Currently I am easily able to do an SQL search on Client (get back a recordset) and use that as a datasource for my Combobox (works great) to display all Customers.
So I need one of the following:
- An SQL call that can take both tables and return a column with Customer and Groupname all in one
- A way to merge two recordsets (I would do 2 SQL calls, one to generate the list of CUSTOMER and the other for GROUPNAMES then merge the recordset and display it)
- Or a way to display 2 columns (either 2 columns in 1 recordset or 2 separate recordsets) as 1 in the Combobox.
I hope that was a clear explanation.
Any ideas would be appreciated.
I might be going about this the wrong way.
-
Aug 24th, 2004, 04:01 PM
#2
simple:
Select CUSTOMER From Client
UNION
Select GROUPNAME From Group
nb: you will only get unique items, and it may be sorted alphabetically (depending on the database you use).
-
Aug 26th, 2004, 11:42 AM
#3
Thread Starter
Hyperactive Member
THANKS!
And would that method be preferable to merging the recordsets after the SQL statement (individual SQL statements)?
-
Aug 26th, 2004, 04:39 PM
#4
You cant really merge recordsets, the next best thing would be to add the items from one recordset to the combobox, then add the items from the other recordset (which would leave duplicates, unless you wrote code to stop that).
-
Sep 3rd, 2004, 11:27 AM
#5
Thread Starter
Hyperactive Member
Thanks!
Since I am using DataSources (and not adding the items) then using the given SQL Statement would probably be the best bet (if this actually puts them in the same Table/Column of the generated recordset).
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|