Under MYSQL 5.6, I have the following 2 tables :
CREATE TABLE User
(
id INTEGER,
login VARCHAR(32),
isservice BOOLEAN
);
CREATE TABLE Certificate
(
userid INTEGER,
serviceid INTEGER,
certificate VARCHAR(32)
);
With the following data :
User:
id | login | isservice
---------------------------
1 | john | false
2 | bob | false
3 | serviceA | true
4 | serviceB | true
Certificate: (example Data, real data in Certificate column are unknown)
userid | serviceid | Certificale
---------------------------
1 | 3 | Alpha
1 | 4 | Bravo
I createdthe following SQLFiddle : http://sqlfiddle.com/#!9/719a8/2
I'm searching for the request (not stored procedure) that would give me the following :
id | login | certif_serviceA | certif_serviceB
-----------------------------------------------
1 | john | Alpha | Bravo
2 | bob | NULL | NULL
So far, I have tried basing my request on :
SELECT user.id, user.login,
service.login as serviceName
FROM User, User as service WHERE service.isservice=1 AND user.isservice=0
But i'm stuck there :s