php - 如何从表中选择除外部表中的值之外的所有值?

标签 php mysql laravel laravel-5

我有三个表:tbl_borrower、tbl_clienttbl_guarantor

tbl_Client:
    id|name|address|email|

tbl_Guarantor:
    id|clientid(fk)|Guaranteed_date|borrower_id(fk from borrower table)

我想检索客户端表的所有值,但 Laravel 5.5 Controller 中担保表中存在的值除外。

最佳答案

建立模型和关系后,您应该执行以下操作:

Client::doesntHave('guarantor')->get()

https://laravel.com/docs/5.6/eloquent-relationships#querying-relationship-absence

关于php - 如何从表中选择除外部表中的值之外的所有值?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52192625/

相关文章:

php - PHP 中的 $stmt 是什么

PHP try/catch 和 fatal error

php - 使用SPACE php mysql从下拉列表到单列插入的多个值

mysql - 从单个表中检索数据以与mysql中的另一个表进行比较

php - Laravel:在自定义类中重定向?

php - Symfony2 "Parameter ""for route ""must match "[^/]++"(""given) to generate a corresponding URL."

php - 播放在线视频

mysql - SQL在Rails中查询的位置

php - 如何在 Lumen 中使用助手实现驱动程序模式

laravel - 如何在 Laravel 中使用 Faker 填充嵌套类别表?