加入同一张桌子

时间:2017-06-21 15:06:03

标签: sql oracle

要求:需要弄清楚哪些LoginID Default设置为10设置为Default。规则是,所有LoginID都可以0作为10,但对于给定的LoginID,必须至少有一条记录LoginID Default A 0 A 1 A 1 B 1 B 1 B 1 B 1 C 0 D 0 D 1 E 0 E 1 E 1

表格如下:

dbHelper = new DatabaseHandler(view.getContext());

dbHelper.deleteRamz(ramz.get_id());//this should be your object id
ramzList.remove(position);
notifyItemRemoved(position);

notifyItemRangeChanged(position,getItemCount());
Log.i("item deleted", String.valueOf(ramzList.size()));  

3 个答案:

答案 0 :(得分:1)

最简单的解决方案是使用MINUS运算符。

select loginID from your_table where default = 1
minus
select loginID from your_table where default = 0

这会生成一组登录ID,其default 10没有。

答案 1 :(得分:1)

我倾向于使用-facebookLogin(): Promise<any> { return this.facebook.login(['email']) .then( (response) => { const facebookCredential = firebase.auth.FacebookAuthProvider .credential(response.authResponse.accessToken); this.afAuth.auth.signInWithCredential(facebookCredential) .then( userData => { this.userProfileRef.child(userData.uid).set({ hypes: 23, name: userData.displayName, image: userData.photoURL, friends: userData.friends, }); this.userUID = userData.uid; }) .catch((error) => { console.log("Firebase failure: " + JSON.stringify(error)); }); }) .catch((error) => { console.log(error) }); }} 来解决此类问题:

group by

答案 2 :(得分:0)

你可能正在寻找一些简单的东西:

SELECT DISTINCT LoginID
  FROM yourtable
 WHERE Default = 1
   AND LoginID NOT IN ( SELECT LoginID FROM yourtable WHERE Default = 0)