MySQL 更新枚举
我有一个带有枚举的字段:'preview','active','close'
当我像这样查询时:
$query = "UPDATE albums
SET album_active = preview
WHERE album_id = 3";
$result = mysql_query($query);
if (!$result) die('Invalid query: ' . mysql_error());
我得到:
无效查询:'字段列表中的未知列'preview'
其他查询:
$query = sprintf("UPDATE albums SET
album_active = %s
WHERE album_id = %d",
$_POST['album_active'],
$_POST['album_id']
);
I have a field with enums: 'preview','active','closed'
When I query like this:
$query = "UPDATE albums
SET album_active = preview
WHERE album_id = 3";
$result = mysql_query($query);
if (!$result) die('Invalid query: ' . mysql_error());
I get:
Invalid query: Unknown column 'preview' in 'field list
Other query:
$query = sprintf("UPDATE albums SET
album_active = %s
WHERE album_id = %d",
$_POST['album_active'],
$_POST['album_id']
);
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
尝试将
preview
放在引号中,如下所示:如果没有引号,
preview
将被查询解析器识别为列名称,如下所示:Try putting
preview
in quotes as:Without the quotes
preview
will be recognized by the query parser as a column name, something like: