使用类似的反向查询 - laravel eloquent 或原始 MySQL 查询
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/30010368/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-14 11:29:07 来源:igfitidea点击:
Reverse query with like - laravel eloquent or raw MySQL query
提问by Peter
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
谢谢
回答by Marcin Nabia?ek
Probably you can use not like
operator in this case:
not like
在这种情况下,您可能可以使用运算符:
$object = Related::whereHas( function($q)
{
$q->where('URL', 'not like', 'http%');
)->get();