• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

querry involving multiple tables.

 
Ranch Hand
Posts: 122
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi evry body

i have following tables

USER

EMP_ID(Int)(PK)
FIRST_NAME( VarChar2(20) )
LAST_NAME( VarChar2(20) )
USER_STATUS(int)
PASSWORD( Varchar2(10) )


ROLE

ROLE_ID(Int)(PK)
EMP_ID(Int)(FK--> User.EMP_ID)
ROLES( varchar2(15) )


PRIVILEGE

PRIV_ID(Int)(PK)
EMP_ID(Int)(FK--> User.EMP_ID)
PRIVILEGES( varchar2(15) )




now i want to display name ,id , along with roles and privileges

of all emplyees who have privileges ="SAP" and ROLES="SME"

what could be the possible ways.

i am using MYSQL

thanks and regards.

 
rammie singh
Ranch Hand
Posts: 122
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
i tried these queries


select USER.`EMP_ID`,USER.`FIRST_NAME`,USER.`LAST_NAME`,PRIVILEGE.`PRIVILEGES`
PRIVILEGE.`START_DATE`,PRIVILEGE.`END_DATE`,ROLE.`ROLES`,ROLE.`START_DATE`,ROLE.`END_DATE`,
from USER
left join PRIVILEGE on USER.EMP_ID=PRIVILEGE.`EMP_ID` and PRIVILEGE.`PRIVILEGES`="SAP"
left join ROLE on USER.EMP_ID=ROLE.EMP_ID and ROLE.ROLES="SME";


and



select USER.`EMP_ID`,USER.`FIRST_NAME`,USER.`LAST_NAME`,PRIVILEGE.`PRIVILEGES`
PRIVILEGE.`START_DATE`,PRIVILEGE.`END_DATE`,ROLE.`ROLES`,ROLE.`START_DATE`,ROLE.`END_DATE`,
from USER,PRIVILEGE,ROLE

where (USER.EMP_ID=PRIVILEGE.`EMP_ID` and PRIVILEGE.`PRIVILEGES`="SAP") and (USER.EMP_ID=ROLE.EMP_ID and ROLE.ROLES="SME");


but not getting executed
 
His brain is the size of a cherry pit! About the size of this ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic