您好我在以下SQL语句中收到“解析错误:语法错误,意外的T_STRING”。任何帮助谢谢
$result2 = ($con,SELECT
Customers.CustomerId, JrnlHdr.Reference, JrnlRow.DistNumber, LineItem.ItemId, LineItem.ItemDescription
FROM "JrnlHdr", "JrnlRow", "Customers", "LineItem"
WHERE JrnlHdr.POSOisClosed = 0
AND JrnlHdr.PostOrder = JrnlRow.PostOrder
AND JrnlHdr.CustVendId = Customers.CustomerRecordNumber
AND JrnlRow.temRecordNumber = LineItem.ItemRecordNumber
AND JrnlHdr.JrnlKey_Journal = 11);
答案 0 :(得分:1)
查询应该是一个字符串,使用引号:
$result2 = ($con,'SELECT Customers.CustomerId, JrnlHdr.Reference, JrnlRow.DistNumber, LineItem.ItemId, LineItem.ItemDescription FROM "JrnlHdr", "JrnlRow", "Customers", "LineItem" WHERE JrnlHdr.POSOisClosed = 0 AND JrnlHdr.PostOrder = JrnlRow.PostOrder AND JrnlHdr.CustVendId = Customers.CustomerRecordNumber AND JrnlRow.temRecordNumber = LineItem.ItemRecordNumber AND JrnlHdr.JrnlKey_Journal = 11');
但是,此代码仍会导致其他错误。您需要调用函数来查询数据库,例如mysqli_query
:
$result2 = mysqli_query($con,'SELECT Customers.CustomerId, JrnlHdr.Reference, JrnlRow.DistNumber, LineItem.ItemId, LineItem.ItemDescription FROM "JrnlHdr", "JrnlRow", "Customers", "LineItem" WHERE JrnlHdr.POSOisClosed = 0 AND JrnlHdr.PostOrder = JrnlRow.PostOrder AND JrnlHdr.CustVendId = Customers.CustomerRecordNumber AND JrnlRow.temRecordNumber = LineItem.ItemRecordNumber AND JrnlHdr.JrnlKey_Journal = 11');