Support the ongoing development of Laravel.io →
Database Eloquent

SELECT b.cat_id, b.cat_parent FROM cat AS b LEFT JOIN cat AS a ON b.cat_parent = a.cat_id WHERE b.cat_title = 'Sail' AND b.cat_place_id =4607 AND a.cat_title = 'Garden and plants'

When I write this query in phpmyadmin or in mysqlworkbench i it's all ok But when I write this query in laravel, I get empty array

DB::table('cat AS b') ->leftJoin('cat AS a', 'b.cat_parent', '=', 'a.cat_id') ->where('b.cat_title', '=', $info['filter']) ->where('b.cat_place_id', '=', $info['place']) ->where('a.cat_title', '=', $info['subchapters']) ->get(array('b.cat_id', 'b.cat_parent'));

How can I solve this problem?

Last updated 3 years ago.
0

I am not very sure if this works:

DB::table('cat AS b')

Can you please try executing the query without the aliases and see the result ?

Also, please mark up your post, it's easier to read. There is a link at the bottom of the thread "Learn how to mark up your post here"

Last updated 3 years ago.
0

Sign in to participate in this thread!

PHPverse

Your banner here too?

Zhenyok zhenyok Joined 9 Jul 2014

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2025 Laravel.io - All rights reserved.