mysql or查询语句,具有多个“ OR”语句的MySQL查询

I have a query, that I have tested outside of PHP directly on SQL and still getting the same problem

The idea being that $currentArtist is sent through using the GET method, where this value matches the value in the event_artist columns the information is displayed.

SELECT

*

FROM

`".DBN."`.`events`

WHERE

`event_artist1` OR `event_artist2` OR `event_artist3` = '".$currentArtist."'

";

The problem I have is that it is completely ignoring the WHERE part of the query. It just returns the complete table results and not the results that match $currentArtist.

I have tested $currentArtist and it works fine. I'm at a loss as to how to get the complete statement to work.

I've tried surrounding the OR statements in brackets as in:

(`event_artist1` OR `event_artist2`...) = '".$currentArtist."'

This only returns a result if the $currentArtist is equal to "1" being the first person in the Artists table where their information is stored.

Any help would be greatly appreciated.

解决方案SELECT *

FROM events e

WHERE '$currentArtist' IN (e.event_artist1,e.event_artist2,e.event_artist3);

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值