根据单个参数中的多个值从数据库中获取值 [英] To get the values from databse based on multiple values in a single parameter

查看:64
本文介绍了根据单个参数中的多个值从数据库中获取值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嗨专家

我想要代码在单个参数中传递多个值然后获取值。



例如



我们需要平日和办公室。一些办公室工作在星期一和星期二,一些办公室可能全天工作,一些办公室工作星期五和星期二



这里我的问题是如何获得星期五和星期二工作办公室..如何在单个参数中传递这两个值以及它如何在sql storedprocedure中调用..





请帮助我.. < br $>




提前谢谢

Hi experts
i want code for to pass multiple values in a single parameter then get the values.

for example

we take weekdays and offices. some offices works monday and tuesday, some offices may work all days and some offices works friday and tuesday

here my problem is how to get both friday and tuesday days working offices.. how to pass both values in a single parameter and how it call in sql storedprocedure..


please help me..


Thanks in advance

推荐答案

最好的解决方案是通过开始和结束工作日到您的存储过程,然后在您的存储过程中使用它们来确定您的工作周。
The best solution would be to pass begin and end workdays to your stored procedure and then in your stored procedure use those to determine your work week.


问题不明确。如果您打算询问如何在传递给SQL Server存储过程的参数中传递多个值,您实际上可以将其作为位域传递,并在T-SQL中使用按位AND运算符(&)来获取值。请查看此文章 [< a href =http://www.mssqltips.com/sqlservertip/1218/sql-server-bitwise-operators-store-multiple-values-in-one-column/target =_ blanktitle =New Window > ^ ]了解更多。



如果您打算询问如何检查列中的多个值,可以使用IN子句

The questions is not clear. If you meant to ask how to pass multiple values in a parameter passed to SQL Server Stored Procedure, you can actually pass it as a bitfield and use bitwise AND operator (&) in T-SQL to get the value. Check this article[^] to know more.

If you meant to ask how to check for multiple values in a column, you can use the IN clause
SELECT * FROM MyTable WHERE DayOfWeek IN ('monday', 'thursday', 'friday')


这篇关于根据单个参数中的多个值从数据库中获取值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆