Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

ankurgoel's avatar

SQL query on multiple tables

Hi,

I am building a website with huge database using laravel. I have a filter page on the website like student has to select a country, degree, tag to find a course.

I have 3 tables: University(holds country column) Course( holds degree column) Tag(CourseId and TagId column)

Also please tell me how use laravel model architecture to put where condition on all the three tables:

University extends Model{ public function course() { return $this->hasMany('App/Courses') } } Courses extends Model { public function university() { return $this->belongsTo('App/University') } public function tags() { return $this->hasMany('App/Tags') } }

How to put where condition like countrycode is 1 and degreecode is 1 and tagcode is 1

Please help i am new to laravel and hoping to get a best query here.

0 likes
1 reply

Please or to participate in this conversation.