列等于mysql中的某些内容

时间:2022-09-18 13:22:21

I am interested in how to write mysql query like this => if some column includes multiple exactly same data, how to check if that column value equal to something . for example I have table with column named "local" and I'm checking like that =>

我感兴趣的是如何写这样的mysql查询=>如果某些列包含多个完全相同的数据,如何检查该列值是否等于某事。例如,我有一个名为“local”的列表,我正在检查=>

SELECT (IF(SELECT local FROM database WHERE local='something'),"Equal","NOT Equal");

This gives me error => ERROR 1242 (21000) Subquery returns more than 1 row

这给了我error => ERROR 1242(21000)子查询返回超过1行

How to write this checking code?

如何写这个检查代码?

2 个解决方案

#1


3  

SELECT (IF EXISTS (SELECT local FROM database WHERE local='something'),"Equal","NOT Equal");

#2


0  

select local from database where local in('something','equal','not equal');

#1


3  

SELECT (IF EXISTS (SELECT local FROM database WHERE local='something'),"Equal","NOT Equal");

#2


0  

select local from database where local in('something','equal','not equal');