如何将一个字符串值与多于20个列进行比较 [英] How to compare one string value to more than 20 column together

查看:54
本文介绍了如何将一个字符串值与多于20个列进行比较的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述





今天我面临的问题不是问题,我用谷歌搜索但没有找到任何合适的方法在sql中比较超过20或50列服务器,MYSQL。即如果我有一个类似的查询



Hi,

Today i am facing a problem not an issue, i googled but not found any appropriate method to compare more than 20 or 50 columns together in sql server, MYSQL. i.e. if i have a query like

select * from table1 where (col1,col2,col3,col4,col5,col6,col7,col8,col9,col10,col11,col12,col13,col14,col15,col16,col17,col18,col19,col20) in ('test')





这意味着记录仅在至少有一个时返回该列应具有'test'值。



that's means records return only when at least one of the column should have 'test' value.

推荐答案

像这样使用Sql IN claus ..

Use Sql IN claus like this..
select * from table1 where 'test' in(col1,col2,col3,col4,col5,col6,col7,col8,col9,col10,col11,col12,col13,col14,col15,col16,col17,col18,col19,col20)





ref。

http://stackoverflow.com/questions/14116292/match-multiple-columns-with-same-value-sql [ ^ ]



MSDN SQL IN [ ^ ]


这篇关于如何将一个字符串值与多于20个列进行比较的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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