我在MySQL中有两个表
表1:purchorder
表2:接收
正如您在第一个表中看到的,表pucrhorder
中的RINumbeR已在表receiving
中更新。现在我的目标是做这样的事情。
在发布此问题之前,我尝试对其进行编码,但我的输出是这样的:
,代码是:
Private Sub POHistory_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim con1 As MySqlConnection = New MySqlConnection("server=localhost;userid=root;password=admin1950;database=inventory")
Dim sql1 As MySqlCommand = New MySqlCommand("select purchorder.PONo,purchorder.ItemCode,purchorder.Description,purchorder.OrderQty,receiving.RINo,receiving.ItemCode,receiving.Description,receiving.ReceivedQty from purchorder,receiving where Purchorder.PONo = '" & TextBox1.Text & "' = receiving.RINo = '" & TextBox2.Text & "' GROUP BY Purchorder.ItemCode;", con1)
Dim ds1 As DataSet = New DataSet
Dim adapter1 As MySqlDataAdapter = New MySqlDataAdapter
con1.Open()
adapter1.SelectCommand = sql1
adapter1.Fill(ds1, "MyTable")
DataGridView1.DataSource = ds1.Tables(0)
con1.Close()
End Sub
怎么办?我是否需要在MYSQL中使用联接? Datagridview画?任何帮助表示赞赏。我想要的只是在上面的图像上显示数据(使用黄色标题)
TYSM
答案 0 :(得分:0)
是的,如果您使用JOIN和GROUP BY,您将获得两个表的结果,并且您已分组的列没有重复