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

我正在尝试将条件添加为active is not qual to 1,但我无法弄清楚它是如何在我的查询中正常工作的。


这是我的查询


$career_solutions_data = DB::select("

SELECT

career_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 certification




FROM career_solutions




INNER JOIN categories

ON categories.id = career_solutions.topic_category_id


INNER JOIN career_solutions_format

ON career_solutions_format.id = career_solutions.topic_format_id


INNER JOIN career_solutions_certification

ON career_solutions_certification.id = career_solutions.topic_certification_id


INNER JOIN career_solutions_categories

ON career_solutions_categories.id = career_solutions.topic_subcategory_id


INNER JOIN users

ON users.id = career_solutions.user_id


LEFT JOIN role_users on role_users.role_id = users.id




INNER JOIN privacy_settings

ON privacy_settings.user_id = users.id


WHERE users.deleted_at IS NULL

AND (

(privacy_settings.career_solutions = 0 AND public = 1 )

OR (users.id IN (


SELECT contacts.contact_id

FROM contacts

WHERE contacts.user_id = $id

)

)

)


OR users.id = $id


ORDER BY date desc limit 5000

");



$role = User::with('role')

->where ('id', '=', $id)

->first();

                }

            }


这是我试图添加的内容:


WHERE `career_solutions.active` <> `1`

or

WHERE `active` <> `1`

or

WHERE `active` != `1`

但没有工作。所以,我不需要用 . 显示帖子active = 1。我还有另外 3 个查询,不同的是,我用过这个 : ->where("active","!=",1);,但在这里我不能使用它。


RISEBY
浏览 131回答 1
1回答

catspeake

问题是周围的反引号1: 这指示 MySQL 搜索列名1。尝试&nbsp;WHERE career_solutions.active <> 1
打开App,查看更多内容
随时随地看视频慕课网APP