如何使用存储在sql中的变量中的值来触发查询? [英] how to fire a query using a value stored in a variable in sql ?
本文介绍了如何使用存储在sql中的变量中的值来触发查询?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
字符串t = xyz;
选择 * 来自 table1 其中 name = t;
为什么是这没有响应?
解决方案
如果你想创建一个变量并在查询中使用它,它看起来像这样:
DECLARE @t varchar(15)
SET @t ='xyz'
SELECT * FROM table1 WHERE name = @t
String t=xyz;
select * from table1 where name = t;
why is this not responding ?
解决方案
If you want to create a variable and use it in a query, it would look something like this:
DECLARE @t varchar(15) SET @t = 'xyz' SELECT * FROM table1 WHERE name = @t
这篇关于如何使用存储在sql中的变量中的值来触发查询?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文