vb.net中的内部联接SQL语法 [英] Inner join SQL syntax in vb.net

查看:111
本文介绍了vb.net中的内部联接SQL语法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是我选择的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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆