Click here to Skip to main content
15,040,003 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have two tables. In the first table, the data are vertical order that is in the same column. But in the second table, the datas are horizontal. I have difficulty in joining them. I am using asp classic and access datatable.

What I have tried:

I have two tables. In the first table, the data are vertical order that is in the same column. But in the second table, the datas are horizontal. I have difficulty in joining them. I am using asp classic and access datatable.

The name of the first table is "Siniflar" It is like that:

id  sinifi       sin_id
1   9-A          S1
2   9-B          S2
3   10-A         S3
4   10-B         S4
5   11-A         S5 
6   11-B         S6
7   11-C         S7
8   11-D         S8
9   11_E         S9
10   12-A        S10
11  13-B         S11
12  12-C         S12
13  12-D         S13

The name of the second table is "tizin25". It is like that:

id   konu_id   test_id    s1   s2     s3   s4 s5 s6 s7 s8 s9 s10 s11 s12 s13
1    102        2         True  True  False  .. etc

How can we join the values in the column sin_id with the columns s,s2,s3....etc in the values in the second table?
Posted
Updated 9-Jul-21 21:55pm

To make your first table horizontal; you are going to need to create a PIVOT query on it.
Create PivotTable or PivotChart views in an Access desktop database - Access[^]

However, you probably are going to actually need to UNPIVOT your second table which is not an Access function. You will need to fake it though, either by some creative VBA code or by using a slew of UNIONs within the query
how to 'unpivot' table | Access World Forums[^]
   
How can we solve this problem with sql codes?
   
First of all, you need to rotate the data in vertical form, for this, you can use pivot and on the second step, you can use where clause to select specific columns.
   
Comments
Richard MacCutchan 10-Jul-21 4:10am
   
Already explained (in detail) a year ago in Solution 1.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900