PC Review


Reply
Thread Tools Rate Thread

Merging two tables into one table

 
 
efandango
Guest
Posts: n/a
 
      20th Mar 2008
Can anyone help me with this problem, I have been trying umpteen different
ways of doing this with SQL (Which I don't entirely understand...)

I want to merge the contents of two tables, fields into one set of
consolidated fields but in a particular order.

Namely, Run_No and OrderSeq.

This is the SQL:

SELECT A.Run_No, B.Run_No, A.Point_ID, B.Point_ID, A.OrderSeq, B.OrderSeq
FROM tbl_Points AS A INNER JOIN tbl_Points AS B ON (A.Run_No+1=B.Run_No) AND
(A.OrderSeq-9=B.OrderSeq);


I want to merge the first 9 records of A.Run_No with the first 9 records of
B.Run_No, along with their corresponding Order_Seq field.

This is the table I want to merge.

A.Point_ID A.OrderSeq A.Run_No B.Run_No B.Point_ID B.OrderSeq
11 10 1 2 19 1
10 11 1 2 20 2
12 12 1 2 21 3
13 13 1 2 22 4
14 14 1 2 23 5
15 15 1 2 24 6
16 16 1 2 25 7
17 17 1 2 26 8
18 18 1 2 27 9
29 10 2 3 37 1
28 11 2 3 38 2
30 12 2 3 39 3
31 13 2 3 40 4
32 14 2 3 41 5
33 15 2 3 42 6
34 16 2 3 43 7
35 17 2 3 44 8
36 18 2 3 45 9
47 10 3 4 55 1
46 11 3 4 56 2
48 12 3 4 57 3
49 13 3 4 58 4
50 14 3 4 59 5
51 15 3 4 60 6
52 16 3 4 61 7
53 17 3 4 62 8
54 18 3 4 63 9
65 10 4 5 73 1
64 11 4 5 74 2
66 12 4 5 75 3
67 13 4 5 76 4
68 14 4 5 77 5
69 15 4 5 78 6
70 16 4 5 79 7
71 17 4 5 80 8
72 18 4 5 81 9
83 10 5 6 91 1
82 11 5 6 92 2
84 12 5 6 93 3
85 13 5 6 94 4

So that I end up with it looking like this:

Run_No OrderSeq Point_ID
1 1 1
1 2 2
1 3 3
1 4 4
1 5 5
1 6 6
1 7 7
1 8 8
1 9 9
1 10 11
1 11 10
1 12 12
1 13 13
1 14 14
1 15 15
1 16 16
1 17 17
1 18 18
2 1 19
2 2 20
2 3 21
2 4 22
2 5 23
2 6 24
2 7 25
2 8 26
2 9 27
2 10 29
2 11 28
2 12 30
2 13 31
2 14 32
2 15 33
2 16 34
2 17 35
2 18 36
3 1 37
3 2 38
3 3 39
3 4 40
3 5 41
3 6 42
3 7 43
3 8 44
3 9 45
3 10 47
3 11 46
3 12 48
3 13 49
3 14 50
3 15 51
3 16 52
3 17 53
3 18 54
4 1 55
4 2 56
4 3 57
4 4 58
4 5 59
4 6 60
4 7 61
4 8 62
4 9 63
4 10 65


 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Merging Table Data From Two Columns Into One Jack Stone Microsoft Access Database Table Design 2 9th May 2008 10:51 PM
Merging related records when there are multiple one-to-one relationships between two tables Marc Eckhert Microsoft Access Queries 3 20th Feb 2007 06:08 PM
Merging several linked tables into one table =?Utf-8?B?QWRhbQ==?= Microsoft Access 1 24th Jun 2004 06:40 PM
Merging two worksheets into one to create a pivot table Scottie318 Microsoft Excel Misc 1 17th Jun 2004 01:10 AM
Merging two tables (from different sources) into one Loke Kit Kai Microsoft ADO .NET 2 4th Jan 2004 10:37 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 01:48 AM.