2016-10-07 4 views
0

これらのフィールドはすべて表示したいが、そのうち3つは異なるテーブルからのものです。VB.net Mysql 3テーブルへの結合

Dim sql As MySqlCommand = New MySqlCommand("SELECT tblproduct.ProductNo, tblgenericname.genericname, tblproduct.BrandName, tblproduct.Quantity, tblproduct.PurchasedDate, tblproduct.ExpirationDate from tblproduct, tblGenericName where tblproduct.Genericno = tblgenericname.genericno, tblcompany where tblproduct.CompanyNo = tblcompany.CompanyNo and tblcompany.CompanyName like '" & cmb_com_load.Text & "'order by BrandName", con) 
    Dim da As MySqlDataAdapter = New MySqlDataAdapter() 
    Dim ds As DataSet = New DataSet 

    da.SelectCommand = sql 
    da.Fill(ds, "rec") 
    DataGridView1.DataSource = ds 
    DataGridView1.DataMember = "rec" 

答えて

0

あなたのSQL:

SELECT tblproduct.ProductNo, tblgenericname.genericname, tblproduct.BrandName, 
tblproduct.Quantity, tblproduct.PurchasedDate, tblproduct.ExpirationDate 
from tblproduct 
join tblGenericName on tblproduct.Genericno = tblgenericname.genericno 
join tblcompany on tblproduct.CompanyNo = tblcompany.CompanyNo 
where tblcompany.CompanyName like '" & cmb_com_load.Text & "'order by BrandName 
関連する問題