title: I get all values from database by sql
body: <p>So, I have a table <code>countries</code> with a column <code>flag.</code>Here I have codes for every country by id.I tried to join the table in my page by SQL query, but I've got this...And I need to display only the right flag, by the id of country, not all the flags.
  <a href="https://imgur.com/a/2F6Qvdv" rel="nofollow noreferrer">https://imgur.com/a/2F6Qvdv</a></p>
  
  <p>My database structure : table <code>countries</code> , column <code>id</code>, <code>country</code> and <code>flag</code></p>
  
  <p>Here is my code :</p>
  
  <p><em>Controller:</em></p>
  
  <pre><code>
               $data['contact_users'] = DB::table('contacts')
                  -&gt;join('users', 'users.id', '=', 'contacts.contact_id')
                  -&gt;join('industries', 'industries.id', '=', 'users.industry_id')
                  -&gt;join('countries', 'countries.id', '=', 'users.country_id')
                  -&gt;join('organization_types', 'organization_types.id', '=', 'users.organization_type_id')
                  -&gt;join("role_users", "role_users.user_id","=","users.id")
                  -&gt;leftJoin("career_paths", "career_paths.user_id","=","users.id")
                  -&gt;select('users.*', 'industries.industry', 'countries.country', 'organization_types.organization_type', "role_users.role_id", 'career_paths.function_id')
                  -&gt;where('contacts.contact_id', '!=', $id)
                  -&gt;where('users.deleted_at', '=', null)
                  -&gt;whereIn('contacts.user_id', $contact_id)
                  -&gt;whereNotIn('contacts.contact_id', $contact_id)
                  -&gt;whereNotIn('contacts.contact_id', $inviter_id)
                  -&gt;groupBy('contact_id')
                  -&gt;take(4)
                  -&gt;get();      
  
                  $flags = DB::select('SELECT flag FROM countries WHERE country = "India"');
  </code></pre>
  
  <p><em>View:</em></p>
  
  <pre><code>@foreach ($flags as $flag)
  {{ $contact-&gt;country }} &lt;span class="{{ $flag-&gt;flag}}"&gt;&lt;/span&gt;
  @endforeach&lt;/a&gt;&lt;br&gt;
  </code></pre>
  
  <p>With <code>{{ $contact-&gt;country }}</code> I get the name of country and with <code>{{ $contact-&gt;id }}</code> I get the id of country.How can I make a conection between id and flag column?</p>