2016-10-25 45 views
-1

我有一個MySQL表的列是這樣的:S_NO道具價格日期,,,...,。如何將數據插入到MySQL表有列名作爲數

現在,當我將數據插入到通過PHP命名爲28列,我recieving此錯誤:

SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '28='120' where s_no='10''

如何將數據插入此列?

+0

** 1 **,** 2 ** ...... ** 30 **列nam ê???任何理由使用像這樣?但你仍然需要分享你的代碼,因爲列名不是你的查詢語法錯誤的問題。 – devpro

+0

給你的專欄合理的alphbetic名字 – RiggsFolly

+1

或者將所有啞列名稱包裝成''''''''''''' – RiggsFolly

回答

3

根據MariaDB's Identifiers Names reference

Identifiers may be quoted using the backtick character - `. Quoting is optional for identifiers that don't contain special characters, or is a reserved word.

你應該``包裹列名:

`28` = '...' 

However I really recommend changing your schema to have meaningful colum names

+0

非常感謝。它正在工作.. –

+0

@DeepanshuSingh,將不勝感激,如果你能接受的答案。謝謝! – Dekel

0

你可以通過使用反勾

UPDATE table SET `30`='100' WHERE id='1' 
+0

這不正是我在1小時前給出的答案嗎? – Dekel

+0

難道你看不到我寫的查詢嗎? – Jazzzzz

+0

謝謝。它現在正在工作.. –

相關問題