dimanche 3 janvier 2021

How to fetch distinct record From second table in left join

I have three table A,B,C And Structure Is Shown Below

                    Table A
              ----------------------
              |id | text_message   |
              ----------------------
              |1  | first Message  |
              ----------------------
              |2  | second Message |
              ----------------------

                    Table B
           -----------------------------------
           |id  | request_id | approved_status|
           ------------------------------------
           |101 |  1         |    2           |
           ------------------------------------
           |102 |   1        |     1          |
           ------------------------------------
           |103 |   2        |      2         |
           -------------------------------------
           |104 |   2         |     2          |
           -------------------------------------

                       Table C
           --------------------------------------
           |id   |  request_id | approved_status |
           ---------------------------------------
           | 501 |    1        |   1              |
           ----------------------------------------
           |502  |    2        |   2              |
           -----------------------------------------

1)Table B request_id column is foreign key reference Table A id column

2)Table C request_id column is foreign key reference Table A id column

3)Table A has one to many relationship with Table B

4)Table A has one to one relationship with Table C

My question is Below

How to write eloquent query so that We can get all record from Table A and Table C and distinct record i.e distinct request_id from Table B



from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/3obucbt
via IFTTT

Aucun commentaire:

Enregistrer un commentaire