查询MySQL数据库时收到错误:
'where子句'中的未知栏'velvet'
"SELECT ATCOCode,Latitude,Longitude FROM StopCode
INNER JOIN JourneyStopCode ON StopCode.ATCOCode = JourneyStopCode.StopCode
INNER JOIN Journey On Journey.Code = JourneyStopCode.JourneyCode
WHERE JourneyCode = code
AND Journey.Operator = velvet"
我的SQL有什么问题吗?下面是我的表结构。
--------------- --------------------- ----------------
| Journey | | JourneyStopCode | | StopCode |
--------------- --------------------- ----------------
| Code | | JourneyStopCodeID | | StopCode |
| Operator | | JourneyCode | | Latitude |
| Description | | StopCode | | Longitude |
--------------- --------------------- ----------------
答案 0 :(得分:6)
你必须将变量封装到我认为的字符串中。
SELECT ATCOCode,Latitude,Longitude FROM StopCode
INNER JOIN JourneyStopCode ON StopCode.ATCOCode = JourneyStopCode.StopCode
INNER JOIN Journey On Journey.Code = JourneyStopCode.JourneyCode
WHERE JourneyCode = 'code'
AND Journey.Operator = 'velvet'
答案 1 :(得分:0)
试试这个
"SELECT ATCOCode,Latitude,Longitude FROM StopCode
INNER JOIN JourneyStopCode ON StopCode.ATCOCode = JourneyStopCode.StopCode
INNER JOIN Journey On Journey.Code = JourneyStopCode.JourneyCode
WHERE JourneyCode = code
AND Journey.Operator = 'velvet'"