How can I fetch those latest records withRaw Sql syntax
I know how to get it through eloquent with hasOne relationship but i need to do it from joins
`post
- id;
- integer(‘no’);
- string(‘division’);
histories
- id;
- foreignId(‘post_id’);
- longText(‘content’);
- date(‘inspection_date’);`
2
Answers
For example we have users and Answer tables . user can have answered many Answers . And we need to pull the latest Answer associated to each User . $query =
Ref here : Laravel leftJoin only last record of right table.
If you want to use raw SQL queries in Laravel instead of models, you can do it this way.