I have data in two tables that are related using VRCNUM. The following code prepares the MySQL prepared statement
Properties are:
DatabaseConnection As MySQLCommunityServer
RequestPathComponents() As String
[code]Dim my_str As String = (“SELECT *” + _
" FROM " + APIRequest.SQLGetTable + _
" LEFT JOIN Contributions_" + APIRequest.SQLGetTableYear + _
" ON " + APIRequest.SQLGetTable + “.VRCNUM = Contributions_” + APIRequest.SQLGetTableYear + “.VRCNUM” + _
" WHERE LD = ‘" + APIRequest.SQLLDPrepare + _
"’ AND (Party = ‘" + APIRequest.SQLParty + _
“) AND Election_District = '” + APIRequest.SQLEDPrepare + _
"’ AND Street = ‘" + APIRequest.SQLGetStreet + _
"’ ORDER BY (Street) ASC, (House_Number+0) ASC, Apartment ASC")
APIRequest.SQLStatement = APIRequest.DatabaseConnection.Prepare(my_str)
APIRequest.SQLStatement.BindType(0, MySQLPreparedStatement.MYSQL_TYPE_STRING)
APIRequest.SQLStatement.Bind(0, APIRequest.RequestPathComponents(2))
[/code]
The problem is VRCNUM does not return a value which is needed. When I run the data contained in my_str in MySQL Workbench all is good.
I need data from the other table to be included when VRCNUM are in each Table and always returning APIRequest.SQLGetTableYear data
Not certain what is not correct but something is not right. Any thoughts on how to use a JOIN in a MySQL prepared statement? Thanks