Home > php教程 > php手册 > SQL语句中的一些参数如何用变量来代替?

SQL语句中的一些参数如何用变量来代替?

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-06-13 10:04:49
Original
1241 people have browsed it

可以采用exec方法
declare @tempStr varchar(350)
select @tempStr='Update weekcount set [' convert(varchar,@week) ']=[' convert(varchar,@week) '] 1 where
userid=''' replace(@user,'''','''''') ''''
exec(@tempStr)
注意: 使exec不能返回一些变量的值,而且当前的变量值在exec的语句里无效.

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
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 Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template