0

I Have Three Tables, TBL-A, TBL-B, TBL-C, TBL-D

TBL A has records for userstatus

RECID    USRID    USERSTAT    USRNAME
1        1        1           JOHN
2        5        1           HARRY
3        6        4           GARY

TBL B has user details

RECID   USRID   FNAME  MNAME  LNAME MOBNO
1        1      JOHN   F      MOSES 1234567
2        2      MARY          MOSES 5421679
3        5      HARRY         KENEDY 1234567
4        6      GARY          MOLE   1234567

TBL C has additional details only for the user having CAT as 1(in Table A)

RECID   USRID   GRPID
1       1       2
2       5       4

TBL D has details of GRP ID

GRPID   GRPNAME GRPDETAIL
 1      group1   FIRSTGROUP
 2      group2   SECOND GROUP
 4      group4   FOURTH GROUP

On basis of user input of mobno(TBL B) all the record having mobno='xxxxx' along with corresponding records of TBL A(userstat), TBL B(FName, Mname, Lname), TBL C(GRPID)-(if existing else output as null or blank), TBL D (GRPNAME,GRPDETAILS)-(if existing else output as null or blank). should be searched.

PLS Help

2
  • 2
    You can just do this with regular joins and a WHERE clause, specifying the TBLA filter.
    – Molenpad
    Mar 27, 2016 at 19:37
  • That is 4 tables and that is an odd data design
    – paparazzo
    Mar 27, 2016 at 22:03

1 Answer 1

0

Vivek - just use (Left or Right) outer joins. This will make sure that the null values will be shown if the data does not exist within the joined table.

1
  • Thanks dear, but still couldn't get the same, actually not very fluent with sql, pls can u help with a sample query illustrating what you said. Thanks
    – Vivek
    Apr 4, 2016 at 7:22

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.