Eloquent's where()
seems not working when comparing two column values. How to fix it?
Sample code:
->where('table_1.name', '=', 'table_2.name')
But works on:
->where('table_1.name', '=', 'john')
Escaping is unnecessary in this case, you can use whereRaw()
:
->whereRaw('table_1.name = table_2.name')
You can use where column:
->whereColumn('table_1.name', 'table_2.name')
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With