MySQL-如何在多个列上使用像 [英] Mysql - how to use like on multiple columns
本文介绍了MySQL-如何在多个列上使用像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我已经在mysql中搜索了java程序中多列中的单词.列数是可变的. 这个查询是正确的:
I've searched in mysql query a word in multiple column in java program. The number of column is variable. It is correct this query:
select * from customer with (city, name) like%'adelaide'%
推荐答案
您可以使用CONCAT()函数:
You can use CONCAT() function:
select * from customer WHERE concat(city,name) like '%adelaide%'
您可以根据需要向concat函数添加任意多的列. 同样如您所见,我更改了类似的语法'%WORD%',并使用了一个简单的where子句.
You can add as many columns to the concat function as you like. Also as you see I changed your like syntax, '%WORD%' and used a simple where clause.
这篇关于MySQL-如何在多个列上使用像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文