Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

how to query spouse details from person table

User_S9M3BMar 12 2019 — edited Mar 14 2019

Hi All,

I have two tables as shown below .

Table name1: Person_info

PID   person_first_name   person_last_name     person_IND

----------------------------------------------------------------------------

11            ABC                       Joe                             A

12           Judy                       abc                             A

13           Syam                      yxz                            A

14           James                    mq                             A

Table name2 : spouse_info (In this table , if SPS_ID is exists then the record will be there Person_Info .

If it null then other columns values present)

PSID             SPS_ID      spouse_first_name     spouse_last_name    spouse_IND

---------------------------------------------------------------------------------------------------------------

11                12    

13                                                  sama                  yxz                                A

12                11

14                                                  Gnya                  doo                                A    

I am trying to write a query to pick for each person , who is the spouse ? and result should look like this

PID    person_first_name       SPS_ID       spouse_first_name     spouse_last_name    spouse_IND

--------------------------------------------------------------------------------------------------------------------------------

11         ABC                           12                               Judy                  abc                         A

12        Judy                            11                              ABC                  Joe                          A

13        Syam                                                           sama                  yxz                           A

14        James                                                         Gnya                  doo                           A

Thanks

Sai

This post has been answered by L. Fernigrini on Mar 12 2019
Jump to Answer
Comments
Post Details
Added on Mar 12 2019
10 comments
1,239 views