I have two tables and need to retrieve some columns from both tables based on the common key which is ProductID. I tried the following but got an error "Incorrect syntax near the keyword 'JOIN'"
string selectProductStatement =
"SELECT Products.Code, Products.Description,"+
"Products.Category, Products.Price, BookProducts.Author"+
"FROM Products"+
"INNER JOIN BookProducts ON (Products.@ProductID = BookProducts.ProductID)";
SqlCommand comm = new SqlCommand(selectProductStatement, connection);
comm.Parameters.AddWithValue("@productID", productID);
the tables are:
Products
ProductID
Code
Description
Category
Price
BookProducts
BookID PK
ProductID FK
Author
BookProducts.Authorand afterFROM Products