SQL选择NOT IN多个值的语句

时间:2016-05-05 18:03:15

标签: sql

我试图从表中选择一些值,我需要排除其他值。

SELECT term_taxonomy_id FROM wp_term_relationships WHERE object_id = 8 AND 
term_taxonomy_id NOT IN (SELECT term_taxonomy_id FROM wp_term_relationships
WHERE term_taxonomy_id IN (1, 2, 3, 4, 5) )

正如您所见,我想要object_id中的term_taxonomy_id,其中object_id不是1-5。

我不确定在这里做什么,任何帮助都是折旧的!

编辑: 以下是获取正确值的完整查询:

SELECT SUM(A) as [Sum], COUNT(A) as [Count], SUM(A)*COUNT(A) as [Multiply],B
FROM TableA
GROUP BY B
HAVING C > 3

1 个答案:

答案 0 :(得分:1)

使用 private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) { Thread thread = new Thread(new Runnable(){ public void run() { try { new FaceDetector(); } catch (IOException | FrameGrabber.Exception ex) { Logger.getLogger(RegisterService.class.getName()).log(Level.SEVERE, null, ex); } } }); thread.start(); while (thread.isAlive()==false) { try { DatabaseConnectivity ndbc = new DatabaseConnectivity("select",""); ndbc.FrameShow(); } catch (SQLException ex) { Logger.getLogger(RegisterService.class.getName()).log(Level.SEVERE, null, ex); } } } 和显式比较:

IN