Why can't mysql be written like this using update?

WBOY
Release: 2016-08-04 09:20:08
Original
1335 people have browsed it

Write like this

if(!mysql_query("update kxwr (name,sex,old) values ​​('Xiaoming','male','18') where id='1'")){
exit('Modification failed');
}
echo'The modification was successful! ';

Why does it return failure?

If

if(!mysql_query("insert into kxwr (name,sex,old,id) values ​​('Xiaoming','male','18','1')")) {
exit('Add failed');
}
echo'Added successfully! ';

In this way, insert can be successful but update cannot. Why?

Reply content:

Write like this

if(!mysql_query("update kxwr (name,sex,old) values ​​('Xiaoming','male','18') where id='1'")){
exit('Modification failed');
}
echo'The modification was successful! ';

Why does it return failure?

If

if(!mysql_query("insert into kxwr (name,sex,old,id) values ​​('Xiaoming','male','18','1')")) {
exit('Add failed');
}
echo'Added successfully! ';

In this way, insert can be successful but update cannot. Why?

Wrong grammar

<code>$sql=" UPDATE kxwr SET name='小明' sex ='男' old ='11' WHERE id='1' ";</code>
Copy after login

Grammar issues. update table_name set column1=xxx where column2=yyy;This is right

Learn sql first.

update is not used like that

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template