To simplify MySQL query? -


i have 3 table in mysql db follow

`users(id_user - 99911, username - heman, status - manager)

service(id_service - 11, service_name - blabla)

auth_service(id_user - 99911, id_service - 11)

all these 3 table not relational. want in php code. have tried queries display services authorised user manager.

select s.service_name service s    inner join auth_service on s.id_service = a.id_service    inner join users u on a.id_user = 99911  order s.service_name , u.status='manager'; 

but displays multiple times of same records has been sorted. problem? how avoid repeated display of same records?

the following query give services authorized users manager.

select distinct s.service_name, a.id_user service s inner join auth_service  on s.id_service = a.id_service  a.id_user in (select id_user users status = 'manager')  order s.service_name 

Comments

Popular posts from this blog

javascript - Any ideas when Firefox is likely to implement lengthAdjust and textLength? -

matlab - "Contour not rendered for non-finite ZData" -

delphi - Indy UDP Read Contents of Adata -