An example of simplifying SQL statements_PHP tutorial

WBOY
Release: 2016-07-13 17:01:23
Original
871 people have browsed it

For example, assume that the table name is bbs, the field of the number of replies is renum, the variable name is $renum, the record number field is id, the variable name is $id
When we reply to a forum post, we will rewrite the number of replies of the main post. The traditional method Two SQL statements are needed:
//Get the original value
$query1="select renum bbs where id = '$id'";
......
$renum;
//Write back to the database
$query2="update bbs set renum = '$renum' where id = '$id'";
The simplified version is as follows:
$query="update bbs set renum = renum 1 where id = '$id'";
All done in one sentence!

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/631165.htmlTechArticleFor example, suppose the table name is bbs, the field of the number of replies is renum, the variable name is $renum, and the record serial number field is id. Variable name $id When we reply in the forum, we will rewrite the reply number of the main post. The traditional method...
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