简体   繁体   English

在MySQL中选择一个表并在其中设置一个值

[英]Selecting a table and setting a value in it in Mysql

I am trying to write a script that archives a user by setting the value of the archive column to the value of 1 . 我正在尝试编写一个脚本,该脚本通过将archive列​​的值设置为1来归档用户。 I have written the following script to do this, but I am not sure if I am using the syntax correctly as I am am getting the following error. 我已经编写了以下脚本来执行此操作,但是由于出现以下错误,因此我不确定我是否正确使用了语法。

<?php
mysql_query("SELECT FROM archive hqfjt_chronoforms_data_addupdatelead
             WHERE cf_uid = '{cf_uid}'
             SET archive='1';"
) or die(mysql_error());
?>

The error I am getting is: 我得到的错误是:

You have an error in your SQL syntax; 您的SQL语法有误; check the manual that corresponds to your MySQL server version for the right syntax to use near 'WHERE cf_uid = 'c68235f3fb5c3f7fff6247b04c450dd7' SET archive='1'' at line 1 在第1行的'WHERE cf_uid ='c68235f3fb5c3f7fff6247b04c450dd7'SET archive ='1''附近,检查与您的MySQL服务器版本相对应的手册以使用正确的语法。

UPDATE archive , not SELECT archive . UPDATE archive ,而不是SELECT archive Also, you're inviting a visit from little Bobby Tables . 此外,您还可以从Bobby Tables的小桌开始参观。

There's no SET in a SELECT statement, and you're missing the FROM part. SELECT语句中没有SET ,并且您缺少FROM部分。

You need an UPDATE command, perhaps like: 您需要一个UPDATE命令,也许像这样:

UPDATE archive SET archive='1' WHERE cf_uid = '$cf_uid'

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM