gpt4 book ai didi

php - Mysql 使用 OR 的选择语句

转载 作者:行者123 更新时间:2023-11-29 07:20:19 25 4
gpt4 key购买 nike

我对 select 语句还很陌生,所以有人可以帮助我完成我想要完成的 PHP 查询吗?

MYSQL 表中有 5 列(Partner_Name、Partner_Name2、Partner_Name3、Partner_Name4、Partner_Name5)

我当前的 PHP 语句如下所示。

$query = mysqli_query( $connection, "SELECT * FROM tblclients  WHERE tblclients.partner_name =  'Store_1' AND tblclients.package =  'standard' AND tblclients.category = 'all' LIMIT 0, 9"); 

我的目标是拥有这样的东西......

$query = mysqli_query( $connection, "SELECT * FROM tblclients WHERE tblclients.partner_name =  'Store_1' OR tblclients.partner_name_2 =  'Store_1' OR tblclients.partner_name_3 =  'Store_1' OR tblclients.partner_name_4 =  'Store_1' OR tblclients.partner_name_5 =  'Store_1' AND tblclients.package =  'standard' AND tblclients.category = 'all'  0, 9");  

它似乎没有按照我预期的方式返回结果。我这样做是否错误?

最佳答案

试试这个:

$query = mysqli_query( $connection, "SELECT * FROM tblclients WHERE tblclients.package =  'standard' AND tblclients.category = 'all' AND (tblclients.partner_name =  'Store_1' OR tblclients.partner_name_2 =  'Store_1' OR tblclients.partner_name_3 =  'Store_1' OR tblclients.partner_name_4 =  'Store_1' OR tblclients.partner_name_5 =  'Store_1')  0, 9"); 

关于php - Mysql 使用 OR 的选择语句,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36439180/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com