dimanche 29 octobre 2017

Join two table and read second table multiple data with first table in laravel

I wanna join two table in laravel , reads one record from first table and multiple record from second table. The first table has some field that I want to select all. The second table has been connected to first table with foreign key. Show multiple records using comma.

First Table:
-----------
+----+-------------+
| id | some_fields |
+----+-------------+
| 23 |    S.V      |
+----+-------------+
| 24 |    S.T      |
+----+-------------+
| 25 |    S.M      |
+----+-------------+

Second Table:
------------
+----+----------+------------+
| fid| meta_key | meta_value |
+----+----------+------------+
| 24 |   meta_1 |   m_1      |
+----+----------+------------+
| 24 |   meta_2 |   m_2      |
+----+----------+------------+
| 25 |   meta_2 |   m_3      |
+----+----------+------------+

 Output that I want:
+----+-------------+----------------+
| id | some_fields |  meta_value    |
+----+-------------+----------------+
| 24 |     S.T     |   m_1  ,  m_2  |
+----+-------------+----------------+
| 25 |     S.M     |      m_3       |
+----+-------------+----------------+



from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/2ifhUhy
via IFTTT

Aucun commentaire:

Enregistrer un commentaire