我在mysql中有3个表1个用户,2个问题和3个结果。
我写了以下查询。
SELECT q.id,qr.user_id
FROM questions AS q
LEFT JOIN results AS r ON q.id=r.question_id
and r.user_id in (SELECT user_id FROM students)
如果该问题的结果中不存在答案。我想要结果中的问题和用户ID。 例子
user
U1
U2
U3
question
A
B
C
result
A U1 YES
A U2 YES
A U3 YES
B U1 YES
B U2 YES
B U3 YES
C U2 YES
C U3 YES
Desired Output
A U1 YES
A U2 YES
A U3 YES
B U1 YES
B U2 YES
B U3 YES
**C U1 No**
C U2 YES
C U3 YES
请帮助。
答案 0 :(得分:0)
尝试一下
add(book: Book) {
return this.authentication.user.pipe(
take(1),
switchMap(user => {
// Set owner for the backend to handle correctly
book.setOwner(user.uid);
// Add book request
const queueRef = this._afqueue.list(this.ADD_BOOK_QUEUE_PATH);
const pushPromise = queueRef.push({ status: { code: 'NEW' }, ...book })
.then(ref => {
console.log('Request to add a new book added to queue.');
return ref;
}) as Promise<any>;
return from(pushPromise);
}),
switchMap(ref => {
return this._afqueue.object(this.ADD_BOOK_QUEUE_PATH + '/' + ref.key)
.valueChanges();
}),
map(snap => snap['status']),
filter(status => status['code'] === 'SUCCESS' || status['code'] === 'ERROR'),
switchMap(status => {
if (status['code'] === 'SUCCESS') {
return Observable.create(function(observer) {
observer.complete(status['book_id']);
});
//return status['book_id'];
}
else if (status['code'] === 'ERROR') {
throw(status['error']);
}
}),
timeout(60000), // timeout after 60 secondes
);
}