-1

I want to search a data in to a table

My table structure is Table : tbl_clientinfo_dplist

dplist_id    dp_id     dplist
-------------------------------
1             1        aaa
2             1        bbb
3             1        ccc
4             1        ddd
5             2        eee
6             2        fff
7             2        ggg

My Another table structure is Table : tbl_client

client_id      provider_type     group_name      cmp_legal_name
---------------------------------------------------------------
   1              1                 5                  Test1
   2              2                 6                  Test2
   3              3                 7                  Test3
   4              1                 5                  Test4
   5              4                 6                  Test5

dp_id=1 are provider type and dp_id=2 are group name.

how can I search provider type or group name from table?

Here it is my current query

SELECT *
FROM tbl_client
LEFT JOIN tbl_clientinfo_dplist
     ON (tbl_client.provider_type  = tbl_clientinfo_dplist.dplist_id)
         OR (tbl_client.group_name = tbl_clientinfo_dplist.dplist_id)
ddb
  • 2,423
  • 7
  • 28
  • 38
smijith
  • 13
  • 7

1 Answers1

1

Just FYI, the above can be rewritten as follows, which I think is easier to read...

SELECT columns, I, actually, need
  FROM tbl_client c
  LEFT 
  JOIN tbl_clientinfo_dplist l
    ON l.dplist_id IN(c.provider_type,c.group_name)
Strawberry
  • 33,750
  • 13
  • 40
  • 57