2012-05-30 42 views
-1

執行以下mysql查詢時,字段會使用null填充而不是指定的值。NULL在表中填充而不是值

INSERT INTO invoices VALUES( 
slNo='2', mrp='3', PplusT='3.375', 
name='Eraser', code='002', qty='15', 
unitPrice='3', rateOfTax='12.5', taxAmt='0.375', 
cess='0.004', total='50.625', billNo='10001') 

表架構

slNo   int(11)          
mrp    float           
PplusT   float          
name   varchar(50)       
code   varchar(10)       
qty    int(11)     
unitPrice  float     
rateOfTax  float     
taxAmt   float       
cess   float      
total   float   
billNo   varchar(10) 

我試着查詢中使用PHP以及PHPMYADMIN但結果是一樣的。

+0

爲什麼downvote?問題清晰,簡明,主題甚至顯示努力。我認爲這是不公平的,因爲OP不知道答案。 –

回答

3

請檢查manual。與SET

INSERT INTO invoices 
SET slNo=2, mrp=3, PplusT=3.375, 
name='Eraser', code='002', qty=15, 
unitPrice=3, rateOfTax=12.5, taxAmt=0.375, 
cess=0.004, total=50.625, billNo='10001' 

更換VALUES,必須先拆除值引號的數字數據類型,或將嘗試將它們作爲字符串。

+0

賓果!!!!!!!!!!!!!! –

+0

@Xaade woa .. ^這是有效的。我學到了新東西o.O –

+0

謝謝:)我永遠都不會找到這個:) – rjv

0

嘗試unquoting你的號碼......你基本上要插入的字符串到整型和浮點

INSERT INTO invoices VALUES( 
slNo=2, mrp=3, PplusT=3.375, 
name='Eraser', code='002', qty=15, 
unitPrice=3, rateOfTax=12.5, taxAmt=0.375, 
cess=0.004, total=50.625, billNo='10001') 
0

請仔細閱讀說明書http://dev.mysql.com/doc/refman/5.0/en/insert-select.html

 INSERT INTO invoices SET 
      slNo='2', mrp='3', PplusT='3.375', 
      name='Eraser', code='002', qty='15', 
      unitPrice='3', rateOfTax='12.5', taxAmt='0.375', 
      cess='0.004', total='50.625', billNo='10001' 

INSERT INTO invoices (slNo, mrp, PplusT, name, code, qty, unitPrice, rateOfTax,taxAmt, 
     cess, total, billNo) VALUES('2', '3', '3.375', 'Eraser', '002', '15', '3', '12.5', '0.375','0.004', '50.625', '10001') 
0

我可能是錯的,但一個INSERT語句不應該像她那樣:

INSERT INTO invoices (slNo, mrp, PplusT, name, code, qty, unitPrice, rateOfTax, taxAmt, cess, total, billNo) 
VALUES('2', '3', '3.375', 'Eraser', '002', '15', '3', '12.5', '0.375', 
'0.004', '50.625', '10001') 
+0

我也不這麼認爲,但請查看我的答案手冊。這是可以的^^ –

+0

@碎片啊是的,我見過那一個。插入的'SET'是從5.0開始引入的,我相信。 –

相關問題