为了账号安全,请及时绑定邮箱和手机立即绑定

如何在查询中添加不等于的地方

如何在查询中添加不等于的地方

PHP
RISEBY 2022-01-24 09:48:21
我正在尝试将条件添加为active is not qual to 1,但我无法弄清楚它是如何在我的查询中正常工作的。这是我的查询$career_solutions_data = DB::select("SELECTcareer_solutions.id,role_users.role_id,career_solutions.user_id,career_solutions.subject,career_solutions.date,career_solutions.public,career_solutions.views,career_solutions.optional,career_solutions.on_offer,career_solutions.active,users.username,users.profile_picture,categories.category,categories.category_url,categories.color,career_solutions_categories.category as sub_category,career_solutions_format.category as event_format,career_solutions_certification.category as certificationFROM career_solutionsINNER JOIN categoriesON categories.id = career_solutions.topic_category_idINNER JOIN career_solutions_formatON career_solutions_format.id = career_solutions.topic_format_idINNER JOIN career_solutions_certificationON career_solutions_certification.id = career_solutions.topic_certification_idINNER JOIN career_solutions_categoriesON career_solutions_categories.id = career_solutions.topic_subcategory_idINNER JOIN usersON users.id = career_solutions.user_idLEFT JOIN role_users on role_users.role_id = users.idINNER JOIN privacy_settingsON privacy_settings.user_id = users.idWHERE users.deleted_at IS NULLAND ((privacy_settings.career_solutions = 0 AND public = 1 )OR (users.id IN (SELECT contacts.contact_idFROM contactsWHERE contacts.user_id = $id)))OR users.id = $idORDER BY date desc limit 5000");$role = User::with('role')->where ('id', '=', $id)->first();                }            }这是我试图添加的内容:WHERE `career_solutions.active` <> `1`orWHERE `active` <> `1`orWHERE `active` != `1`但没有工作。所以,我不需要用 . 显示帖子active = 1。我还有另外 3 个查询,不同的是,我用过这个 : ->where("active","!=",1);,但在这里我不能使用它。
查看完整描述

1 回答

?
catspeake

TA贡献1111条经验 获得超0个赞

问题是周围的反引号1: 这指示 MySQL 搜索1

尝试 WHERE career_solutions.active <> 1



查看完整回答
反对 回复 2022-01-24
  • 1 回答
  • 0 关注
  • 129 浏览

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信