首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何在查询中添加不等于的位置

如何在查询中添加不等于的位置
EN

Stack Overflow用户
提问于 2019-09-23 07:14:18
回答 1查看 55关注 0票数 0

我试图以active is not qual to 1的形式添加一个条件,但在我的查询中我无法弄清楚它是如何正确工作的。

这里是我的查询

代码语言:javascript
复制
$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();



                // $career_solutions_data;

                foreach ($career_solutions_data as $career_solution)
                {

                    preg_match('/<img.+src=[\'"](?P<src>.+?)[\'"].*>/i', $career_solution->optional, $image);
                    if(isset($image['src']))
                    {
                        $type_picture = $image['src'];
                    }
                    else{
                        $type_picture = "";
                    }

                    $temp_soluation = array();
                    $temp_soluation['type'] = 'Career Solution';
                    $temp_soluation['typee'] = 'briefcase';
                    $temp_soluation['subject'] = $career_solution->subject;

                    $temp_soluation['information'] = $career_solution->optional;
                    $temp_soluation['category'] = $career_solution->category;
                    $temp_soluation['category_url'] = $career_solution->category_url;
                    $temp_soluation['color'] = $career_solution->color;
                    $temp_soluation['all_url'] = 'search-career-solutions';
                    $temp_soluation['type_url'] = 'view-career-solutions';
                    $temp_soluation['id'] = $career_solution->id;
                    $temp_soluation['date'] = $career_solution->date;
                    $temp_soluation['public'] = $career_solution->public;
                    $temp_soluation['active'] = $career_solution->active;
                    $temp_soluation['sub_category'] = $career_solution->sub_category;
                    $temp_soluation['event_format'] = $career_solution->event_format;
                    $temp_soluation['certification'] = $career_solution->certification;
                    $temp_soluation['on_offer'] = $career_solution->on_offer;
                    $temp_soluation['username'] = $career_solution->username;
                    $temp_soluation['roleMe'] = $career_solution->optional;

                              $temp_soluation['role']  = $role->role[0]->id;


                    $temp_soluation['profile_picture'] = $career_solution->profile_picture;
                    $temp_soluation['type_picture'] = $type_picture;
                    // $news_events_opinions[] = $temp_soluation;
                    $my_career_solution[] = $temp_soluation;
                }
            }

这就是我想补充的:

代码语言:javascript
复制
WHERE `career_solutions.active` <> `1`
or
WHERE `active` <> `1`
or
WHERE `active` != `1`

但是没有working.So,我需要不显示带有active = 1.I的帖子,还有另外3个查询,不同的是,我使用了以下内容:->where("active","!=",1);,但在这里我不能使用它。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2019-09-23 07:17:20

问题是1周围的回退:这指示MySQL搜索名称1

试试WHERE career_solutions.active <> 1

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/58057358

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档