您好,我想显示值table1和table2中的值,并在datagridview中一起显示它们。 但是我的输出显示的是重复值,而不是2个值,它又显示了4个具有相同值的值
query = "select receive_bardana.bales,receive_wheat.bags from receive_bardana
inner Join receive_wheat
On receive_bardana.id= receive_wheat.id
where receive_bardana.id ='1'"
我的输出是:
+-------+------+ | BALES | BAGS | +-------+------+ | 100 | 1000 | | 1000 | 1000 | | 100 | 2000 | | 1000 | 2000 | +-------+------+
我存储在表中的是:
+-----+-------+ | ID | BALES | +-----+-------+ | 1 | 100 | | 1 | 1000 | +-----+-------+
+-----+------+ | ID | BAGS | +-----+------+ | 1 | 1000 | | 1 | 2000 | +-----+------+
ID是两个表之间的关系。例如。我有两个下班族。
ID是ID号血腥之城
1 FOR GODOWN1
AND 2 GODOWN 2
主键是自动增加值。
答案 0 :(得分:0)
您可以做的是添加一个额外的ID2行
query = "select receive_bardana.bales,receive_wheat.bags from receive_bardana
inner Join receive_wheat
On receive_bardana.id2 = receive_wheat.id2
where receive_bardana.id ='1'"
|ID | ID2 | BALES
| 1 | 1 | 100
| 1 | 2 | 1000
+-----+------+------+
|ID | ID2 | BAGS
| 1 | 1 | 1000
| 1 | 2 | 2000
+-----+------+------+