Home > Backend Development > PHP Tutorial > How to replace some parameters in SQL statements with variables?_PHP Tutorial

How to replace some parameters in SQL statements with variables?_PHP Tutorial

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-07-13 17:00:58
Original
1103 people have browsed it

You can use the exec method
declare @tempStr varchar(350)
select @tempStr='Update weekcount set [' convert(varchar,@week) ']=[' convert(varchar,@week) '] 1 where
userid=''' replace(@user,'''','''''') ''''
exec(@tempStr)
Note: Make exec unable to return the value of some variables , and the current variable value is invalid in the exec statement.

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/631206.htmlTechArticleYou can use the exec method declare @tempStr varchar(350) select @tempStr='Update weekcount set [' convert(varchar ,@week) ']=[' convert(varchar,@week) '] 1 where userid=''' replace(@user...
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
Latest Issues
sql file
From 1970-01-01 08:00:00
0
0
0
php - Overhead of prepare vs sql?
From 1970-01-01 08:00:00
0
0
0
Print sql statement
From 1970-01-01 08:00:00
0
0
0
Pass array to SQL insert query using PHP
From 1970-01-01 08:00:00
0
0
0
sql optimization or
From 1970-01-01 08:00:00
0
0
0
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template