我试图执行以下操作:
UPDATE door_instances SET pt_id = '9906662', 0221RUMSNUMMER = 'C0962', 0311HNGNINGHV = 'V', 0312Angreppssida = 'Gångjärnssida', 083FUNKTIONSKRAVLJUDISOLERINGKlassR\'wdB = '30', 131KARMVGGTJOCKLEK = '145', ingrejirapport = 'Nej', isFinished = 'Nej', isNew = 'Nej', 211FRKLARINGAROCHFRESKRIFTER = '', 212GRNSDRAGNING = '', 213KANALISATIONDRRMILJ = '', 215RITNINGAR = '', 216DETALJER = '', 214BESKRIVNINGAR = '' WHERE id IN (105239)
但由于其中一列的名称中有引号(083FUNKTIONSKRAVLJUDISOLERINGKlassR \' wdB),我收到此错误:
#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 '\'wdB = '30', 131KARMVGGTJOCKLEK = '145', ingrejirapport = 'Nej', isFinished = '' at line 1
任何想法或建议将不胜感激。
常见的MySQL大师。
答案 0 :(得分:1)
简短:不要这样做。
更长:您可以使用反引号`来引用列名:
...da', `083FUNKTIONSKRAVLJUDISOLERINGKlassR'wdB` = '30', 131KARMVG...
在PHP中使用它们,将它放在单引号或双引号之间:
$key = '`'.$key.'`'
或
$key = "`$key`"