Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
How do I extract the data from 2 tables (A & B)and form table C? Using IF....Else or CASE?
Table A
order_no Name
001 Jacky
002 Jimmy
003 Jenny
Table Border_no Tel
001 1234567
003 7654321Table A + Table B
order_no Name Tel
001 Jacky 1234567
002 Jimmy
003 Jenny 7654321

If you are in Excel, and you want to do this with a formula on the sheet (rather than by macro), then:
A B C D E F G H
1 001 Jacky 001 12345 001 **
2 002 Jimmy 003 54321 002
3 003 Jenny 003**: =vlookup(G1,A$1:B$3,2,false) & " " & vlookup(G1,D$1,E$2,2,false)
Then copy down formula from G1 to G3
Note the structure of the vlookup command:
=vlookup([what],[table - 1st column for match],[returned column from table],[false=exact match])Post back if you don't follow this.
Tom

Sorry - I now see how this board deals with multiple spaces!!
The tables are in: A/B then C is blank, the next is in D/E and F is blank. Then the code is in G and the formula goes into H1 and copies down to H3.
Apologies for being an arse.
Tom

I'm not in Excel but in MS SQL 6.5.
I need to write a query statement to do so.
Much appreciation for your help.

This is the SQL generated by Access to do this:
SELECT [Table A].[Order No], [Table A]![Name] & " " & [Table B]![Telephone No] AS Expr1 INTO [Table C]
FROM [Table A] LEFT JOIN [Table B] ON [Table A].[Order No] = [Table B].[Order No];Note that this make a new table, includes ALL rows from table A and only those rows from table B where there is matching information. Were you to have a fourth customer with telephone number (ie, in table B) but no name (ie, no entry in table A) then they would be omitted.
Hope this helps.
Tom

![]() |
SQL 6.5 Help
|
mailslot
|

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.
| Ads by Google |