to JOIN or INNER JOIN, that is the question...
Hi,
I have two tables (well that are required for this function anyway)
- tbl_Items
- tbl_Bids
and this is my code:
VB Code:
Sub imgcmd_Search_Click(sender As Object, e As ImageClickEventArgs)
Dim MyConnection = New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;data source=" & _
server.mappath("cgi-bin/db/orctions.mdb"))
Dim CommandText As String = "SELECT * FROM tbl_Items WHERE SearchData like '%" & txt_Search.text & "%'"
Dim myCommand As New OleDBCommand(CommandText, myConnection)
myConnection.Open()
rep_Search.DataSource = myCommand.ExecuteReader(CommandBehavior.CloseConnection)
rep_Search.DataBind()
End Sub
what I need to do is get the Fields 'Bidder' and 'BidValue' from 'tbl_Bids' as long as it matches the critera in the Where Clause which is looking at the 'tbl_Itmes'
I hope that is clear enough ... ? :rolleyes:
Any help would be great thanks
Re: to JOIN or INNER JOIN, that is the question...
Quote:
Originally posted by §tudz
Hi,
I have two tables (well that are required for this function anyway)
- tbl_Items
- tbl_Bids
and this is my code:
VB Code:
Sub imgcmd_Search_Click(sender As Object, e As ImageClickEventArgs)
Dim MyConnection = New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;data source=" & _
server.mappath("cgi-bin/db/orctions.mdb"))
Dim CommandText As String = "SELECT * FROM tbl_Items WHERE SearchData like '%" & txt_Search.text & "%'"
Dim myCommand As New OleDBCommand(CommandText, myConnection)
myConnection.Open()
rep_Search.DataSource = myCommand.ExecuteReader(CommandBehavior.CloseConnection)
rep_Search.DataBind()
End Sub
what I need to do is get the Fields 'Bidder' and 'BidValue' from 'tbl_Bids' as long as it matches the critera in the Where Clause which is looking at the 'tbl_Itmes'
I hope that is clear enough ... ? :rolleyes:
Any help would be great thanks
You should try something like this. You need to fill in the common table column between them (identified with the SOMECOLUMN word)
"SELECT b.Bidder, b.BidValue FROM tbl_Items a
JOIN tbl_Bids b,
ON a.SOMECOLUMN = b.SOMECOLUMN
WHERE a.SearchData like '%" & txt_Search.text & "%'"