我尝试创建一个查询不同用户的问题和答案。我的目标是将不同的表连接在一起以创建我想要的结果。当前,SQL查询总是在注释列中,即从提出问题的用户处生成相同的内容。因此,根本不会输出UserA的答案。我将 INNER JOIN 更改为 LEFT / RIGHT ,然后可以使用,但是问题(评论)消失了。
.controller('pASSWORDGMCtrl', ['$scope', '$stateParams', 'aaaService',
function ($scope, $stateParams, aaaService) {
$scope.user = {
email:"",
pass:"",
}
$scope.signIn = function(){
aaaService.login($scope.user.email, $scope.user.pass);
}
aaaService.status();
$scope.signOut = function(){
aaaService.signout();
}
}])
我还尝试了使用SQL语句“ UNION” 的不同方法,但是UserQ和UserA之间存在明显的分隔,这意味着当填充另一列时,其中一列始终为空
angular.module('firebaseAaa', ['firebase'])
.factory('aaaService', ['$firebaseArray','$firebaseAuth',
function($firebaseArray, $firebaseAuth){
var config = {
apiKey: "",
authDomain: "",
databaseURL: "",
projectId: "",
storageBucket: "",
messagingSenderId: ""
};
if(!firebase.apps.length){
firebase.initializeApp(config);
}
var ref;
var adminArray;
return{
status: function(){
firebase.auth().onAuthStateChanged(function(user) {
if (user) {
// User is signed in.
// if(loggingIn){
alert("Login success.");
ref = firebase.database().ref().child("Admin/" + user.uid);
adminArray = $firebaseArray(ref);
}
// loggingIn=false;
else {
// No user is signed in.
}
});
},
login: function(email, pass) {
firebase.auth().signInWithEmailAndPassword('abc@gmail.com', 'aaa').catch(function(error) {
// Handle Errors here.
var errorCode = error.code;
var errorMessage = error.message;
alert("Error signing in user: ", errorCode + " " + errorMessage);
});
},
signout: function() {
firebase.auth().signOut().then(function() {
// Sign-out successful.
alert("You are now signed out.");
// loggingIn= false;
}).catch(function(error) {
// An error happened.
// Handle Errors here.
var errorCode = error.code;
var errorMessage = error.message;
alert("Error signout: ", errorCode + " " + errorMessage);
});
},
}
}])
答案 0 :(得分:0)
您尝试过吗?
SELECT C.username UserQ,
R.username UserA,
C.commentID,
D.Title,
C.text Comment
FROM Comments C
JOIN Detail D
ON C.vID = D.vId
JOIN Search S
ON C.vID = S.vID
LEFT OUTER JOIN Replies R
ON C.commentID = R.CommentID_ParentID
WHERE D.categoryId = 25
AND S.searched_keyword = 'stackoverflow'
ORDER
BY commentID,
replyID
实际上,为什么不使用一些示例数据创建SQLfiddle?
答案 1 :(得分:0)
INER JOIN,OUTER JOIN,FULL JOIN,LEFT JOIN