我有这个 sql 字符串:
Dim sqlQuery As String = "SELECT TOP 1 ID, FName, FoodGroup, Calories, Protein, Carbohydrates, Fat, category.ID" &
" FROM food where Protein<='" & txtProt.Text.ToString() & "' and FoodGroup = 4 " & "and category.ID = 1 " & "JOIN foodCategory ON food.ID = foodCategory.Food_ID" & "JOIN category ON foodCategory.Category_ID = category.ID " & "ORDER BY NEWID() "
我想做的是:我想从表“食物”中输入值“FName”到一个文本框,其中表“类别”的“ID”字段为 1。
我有 3 张桌子。第一个是餐桌食品,第二个是餐桌类别,第三个是 foodCategory。表 foodCategory 具有从前 2 个表到一对多关系的 ID。我收到以下错误:JOIN 附近的语法不正确。我做错了什么?