Click to See Complete Forum and Search --> : Why wont this INNER JOIN work


scottie_uk
May 10th, 2003, 02:48 PM
I am joining two tables together using INNER join. I want some of the feilds from one table (stockLevels) and some fields from the other (productFile).

When select all fields it works fine:

SELECT * FROM stockLevels INNER JOIN productFile ON productFile.ProductID = stockLevels.productID;


but when I start to choose the fields Even one I get an error.


Dim sqlQuery2 As String = "select stoclLevels.name, productFile.costPrice from stockLevels INNER JOIN productFile ON productFile.ProductID = stockLevels.productID"



No value givern fore one or more paramiters.


The SQL command I would like to execute is:


Dim sqlQuery2 As String = "SELECT productFile.supplierID, productFile.productID, productFile.ProdctName, productFile.costPrice, productFile.servingsPerUnit, stockLvels.servings, stockLevels.reorderLevel, stockLevels.NormaLevel FROM productFile INNER JOIN stockLevels ON productFile.ProductID = stockLevels.productID ;"



Thanks for reading an please help:(

scottie.uk

wolfofthenorth
May 11th, 2003, 01:11 AM
Did you check the spelling of all the fields? In the example you posted one of the fields is spelled wrong, stockLvels.servings.

scottie_uk
May 11th, 2003, 01:54 PM
Thanks that was an error, I did manage to get it working after a while. Some of the words in the original database had spaces between them, wheres in my code I did not.

Thanks for the help.

:D

dharmapurikar
May 12th, 2003, 04:19 AM
When u use all the fields that quary possess all the names in database exactly as they are in queries but in the following query u used first filed as follows "stoclLevels.name" and this field really not present your field might be as follows "stockLevels.name"

so u retype this quary or just pick the following query.

Dim sqlQuery2 As String = "select stockLevels.name, productFile.costPrice from stockLevels INNER JOIN productFile ON productFile.ProductID = stockLevels.productID"


Hope it will solve your problem


:cool: