php - 使用 Where 子句插入

标签 php mysql sql

我在使用 where 子句插入数据时遇到问题。这是查询:

    $hi= "INSERT INTO user_detail (email, looking, username, profession, experience,
         current_work, state, job_type, about, college, diploma, department)
             VALUES ('$email', '$looking', '$username', '$profession','$experience',
     '$current_work', '$state', '$job_type', '$about', '$college', '$diploma', '$department')
 WHERE s='$username'";

它告诉我错误:

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 'WHERE s='aniket276'' at line 1

最佳答案

使用MySQL更新

像那样:-

UPDATE user_detail SET email='$email' WHERE s='$username';

You should rather use UPDATE, if you want to change the value of the field in records you select using the WHERE clause

关于php - 使用 Where 子句插入,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33437626/

相关文章:

PHP下拉列表不选择值

PHP mysql 计算两列之间

api - 什么时候应该抛出异常而不是在 PHP 中返回错误?

php - 查询未插入值

php - 如何在 Laravel 中使用另一个字段进行身份验证?

mysql - 在SQL中选择具有相同ID的另一行时字段的聚合总和

MySql:如何按 2 个特定类别然后按价格对查询进行排序?

php - PDO: Assets 和 session 未正确显示

php - 在 mysql 中更新日期和时间时如何修复 laravel 的错误日期和时间

sql - 具有不同参数的 2 个相同的 sql 查询 - 只有一个需要临时表