0

有人知道问题出在哪里吗?它一定只是逗号或拼写错误,但我正在看这 5 行 2 小时,但仍然看不到它,也许有人可以很快看到它。

错误 SQL 查询:

INSERT INTO SalesOrder
(

Customer, ContactName, Phone, Email, BillingAddress1, BillingAddress2, BillingCity, BillingState, BillingCountry, BillingPostalCode, BillingAddressRemarks, ShipToCompanyName, ShippingAddress1, ShippingAddress2, ShippingCity, ShippingState, ShippingCountry, ShippingPostalCode, ShippingAddressRemarks, CurrencyCode, ExchangeRate, PricingScheme, PaymentTerms, TaxingScheme, Tax1Rate, Tax2Rate, CalculateTax2OnTax1, Tax1Name, Tax2Name, TaxOnShipping, Custom1, Custom2, Custom3, ItemName, ItemDescription, ItemQuantity, ItemQuantityUoM, ItemUnitPrice, ItemDiscount, ItemSubtotal, ItemTaxCode
) VALUES (
'Yu',  'Yau ',  '01224 580318',  '',  '',  '',  '',  '',  '',  '',  '',  '',  '',  '',  '',  '',  '',  '',  '',  'GBP',  '1',  '',  '',  '', 0, 0,  'FALSE',  '',  '',  'FALSE',  '',  '',  '',  'Vg0003',  'Apple Green', 2,  'box',  '15.5',  '0%';

MySQL said: 

#1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'Customer,ContactName,Phone,Email,BillingAddress1,BillingAddress2,BillingCity,Bil' at line 1 
4

3 回答 3

5

缺少右括号:

VALUES ( ... ) ;
            ^^^
于 2013-02-06T18:12:43.280 回答
1

可能是因为您在值之后错过了右括号。它应该正确地采用以下形式:

$sql = mysql_query("INSERT INTO table () VALUES ()");
于 2013-02-06T18:14:54.117 回答
0

此评论位于答案框中,因此它会显示得更好。另外两个答案是正确的。

如果您像这样键入查询,则此类问题的发生频率将降低:

insert into yourtable 
(f1
, f2
, f3
-- etc
, f10
)
values
(v1
, v2
, v3
-- etc
, v10
)

它使您的所有括号都可见。您不太可能有额外的逗号。此外,在开发查询时,如果遇到困难,更容易注释掉字段和值集。

于 2013-02-06T18:39:40.547 回答