vb.net中的内部联接SQL语法 [英] Inner join SQL syntax in vb.net
问题描述
这是我选择的SQL语法,用于显示类别选择, 但是我需要做的是显示根据equipment_id选择的相应类别
This is my select SQL syntax to display the category choices, but what I need to do is display the corresponding category chosen based on equipment_id
我有2个表,tblOfficeEquipmentCategory和tblOfficeEquipmentProfile
I got 2 tables, tblOfficeEquipmentCategory and tblOfficeEquipmentProfile
我需要内部加入tblOfficeEquipmentProfile,因此我可以添加WHERE equipment_id ='"txtid.text"'
I need to inner join tblOfficeEquipmentProfile so I can add the WHERE equipment_id = '"txtid.text"'
对应的SQL语法是什么
What would be the corresponding SQL syntax
Public Sub DisplayCategory()
'based on oe_id
Dim sqlconn As New SqlClient.SqlConnection
sqlconn.ConnectionString = "server = SKPI-APPS1;" & _
"Database = EOEMS;integrated security=true"
Dim sqlcommand As SqlCommand
sqlconn.Open()
Dim da As New SqlDataAdapter("select * from tblOfficeEquipmentCategory", sqlconn)
Dim dt As New DataTable
da.Fill(dt)
cmbCategory.DataSource = dt
cmbCategory.ValueMember = "CAT_Name"
cmbCategory.DisplayMember = "CAT_ID"
sqlconn.Close()
End Sub
推荐答案
假定equipment_id
位于表tblOfficeEquipmentProfile
上,并且列CAT_ID
位于将其链接到表tblOfficeEquipmentCategory
上.
Assuming equipment_id
is located on table tblOfficeEquipmentProfile
and a column CAT_ID
which links it to table tblOfficeEquipmentCategory
.
SELECT a.CAT_Name
FROM tblOfficeEquipmentCategory a
INNER JOIN tblOfficeEquipmentProfile b
ON a.CAT_ID = b.CAT_ID
WHERE b.equipment_id = @ID
要进一步获得有关联接的知识,请访问下面的链接:
To further gain more knowledge about joins, kindly visit the link below:
这篇关于vb.net中的内部联接SQL语法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!