I am trying to select all (*) the data columns on one table accompanied by INNER JOINing another table to get the menu item name. Please have a look at my query
string query = "SELECT ol.*, m.menu_name " +
"FROM orderlist ol " +
"INNER JOIN menudb m " +
"ON m.menu_ID = ol.menu_ID " +
"WHERE ol.order_ID = @orderID";
I can’t seem to get the m.menu_name when I retrieve it using dr["menu_name"].ToString()
Any ideas why?
orderlist Table Columns
orderlist_ID order_ID menu_ID order_quantity
menudb Table Columns
menu_ID menu_name menu_price menu_description menu_category menu_status
There are many problems in your query.
First, you have a syntax error due to lack of spaces between keywords.
you should have add an extra space after
ol.menu_IDSecond, if you parameterized the query, you should not wrap the parameter with a single quote. This causes to be a string and not a parameter anymore.