1. combining data into one table from multiple tables
Hello fellows,
I would appreciate if somebody can help me out. I am very new to SQL and
seems that can not find solution to my problem:
I have a single database with say three tables:
Table1:
Table1ID (int) , Description (varchar) - contains two letter codes space
separated, different number of codes for each row (row1: AB CD, row2: CD EF
GH)..., and other columns not relevant
Table2:
Table2ID (int) - two digit ids (10, 20, 30) which will represent those
letter codes from above table1 (10=AB, etc.). However there are no
relationship in a database yet, I just KNOW what those digit codes suppose
to match from letter codes
Description (varchar) - just a description
I need to create Table3 which will contain keys (Table1ID, Table2ID), where
I need to combine those tableids according that information that I have,
something like:
IF
Table1
Table1ID: 100 , Desc: AB, BC
AND
Table2
Table2ID: 10 ( and I know it means AB), Desc: area01
Table2ID: 20 (BC), Desc: area02
THEN
Importing into Table3:
Row1: 100, 10
Row2: 100, 20
So far I was able only to find a way to separate description codes by two in
each column (one by one) in temp table such us:
SELECT Table1ID,
[description info],
substring([description info],1,2) as test1,
substring([description info],4,2) as test2,
substring([description info],7,2) as test3,
substring([description info],10,2) as test4,
substring([description info],13,2) as test5,
substring([description info],16,2) as test6,
substring([description info],19,2) as test7,
substring([description info],22,2) as test8,
substring([description info],25,2) as test9,
substring([description info],28,2) as test10,
substring([description info],31,2) as test11,
substring([description info],34,2) as test12,
substring([description info],37,2) as test13
into #mytemp
from Table1
SELECT*
into #mytemp2
from #mytemp where
And from here I stuck. I know that I am probably suppose to use INSERT
statement, but all my tests failed so far. Please advise how I can proceed
next, if it possible with a code example. Thank you.
BTW, I am working with MSDE 2000 (winXP) and SQL 2000 enterprise manager.
George
2. Accessing DB2 on OS/390 via MS Access
3. How to convert an Universe Hashed data file to be an ASCII flat file?
4. combining data into one table from multiple tables - please disregard a previous one, wrong email
5. putting bitmaps INTO a dbase blob field?
6. How do I tell if an existing informix table is a virtual table
7. Sql Server 2000 Cluster Question - Virtual Names
8. Pivot Table on IE
9. how to print pivot table in IE
10. SQL Problem - combine flat file and table rows
11. combining same field from 2 tables
12. combining two tables