Computing.Net > Forums > Programming > Extracting Data from 2 tables!!!

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

Extracting Data from 2 tables!!!

Reply to Message Icon

Name: IT_idiot
Date: February 21, 2002 at 00:19:30 Pacific
Comment:

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 B

order_no Tel
001 1234567
003 7654321

Table A + Table B

order_no Name Tel
001 Jacky 1234567
002 Jimmy
003 Jenny 7654321



Sponsored Link
Ads by Google

Response Number 1
Name: A Certain TH
Date: February 21, 2002 at 04:30:10 Pacific
Reply:

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


0

Response Number 2
Name: A Certain TH
Date: February 21, 2002 at 05:41:59 Pacific
Reply:

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


0

Response Number 3
Name: IT_idiot
Date: February 21, 2002 at 20:36:19 Pacific
Reply:

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.


0

Response Number 4
Name: A Certain TH
Date: February 22, 2002 at 03:24:39 Pacific
Reply:

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


0

Sponsored Link
Ads by Google
Reply to Message Icon

Related Posts

See More


SQL 6.5 Help mailslot



Post Locked

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


Go to Programming Forum Home


Sponsored links

Ads by Google


Results for: Extracting Data from 2 tables!!!

Extracting data from an array in C www.computing.net/answers/programming/extracting-data-from-an-array-in-c/8130.html

Extracting data from XML to VB 6 www.computing.net/answers/programming/extracting-data-from-xml-to-vb-6/4148.html

php data from table mysql newbie www.computing.net/answers/programming/php-data-from-table-mysql-newbie/13702.html