Sql logic needed

Hello People I have two tables…

- id (
- username

sample data (1:alex,2:rocky,3:kothi)

- from_id
- to_id
sample data (1:2,1:3)

I want to fetch and display from_name and To_name from linked_table.i tried joining and selecting but it fetches only from_name

    $Get_Linked_name = DB::table('linked_table')

'linked_table.from_id'=>1 is linked to 2,3 now i want to fetch username of 2,3 i know it can be done using another empty array and foreach loop but is there any other better options?

updated: From_name and To_name are nothing but username of users table

Source: sql

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.