使用like-laravel eloquent或原始MySQL查询进行反向查询

时间:2022-10-25 07:47:25

I have a table with links submitted by users. Some of the links do not contain the

我有一个表,其中包含用户提交的链接。有些链接不包含

`http://`

I want to list these records by using the below query:

我想使用以下查询列出这些记录:

        $object = Related::whereHas( function($q)
                {
                $q->where('URL', 'like', 'http%');

                    })->get();

How to reverse the query to get them?

如何反转查询以获取它们?

Thx

1 个解决方案

#1


Probably you can use not like operator in this case:

在这种情况下,你可以使用不像运算符:

$object = Related::whereHas( function($q)
{
    $q->where('URL', 'not like', 'http%');

)->get();

#1


Probably you can use not like operator in this case:

在这种情况下,你可以使用不像运算符:

$object = Related::whereHas( function($q)
{
    $q->where('URL', 'not like', 'http%');

)->get();