我有一个users表,一个categories表和一个user_category表作为pivot。我想从类别表中选择多个ID,然后生成一个查询,该查询仅显示不属于所选类别之一的用户的记录。
因此,如果用户是两个类别的成员,并且我选择在我的“不是”中排除其中一个类别。查询,它们不会出现在我的结果中。
这就是我现在所拥有的:
select distinct users.id, users.firstname, users.lastname, users.email from users INNER JOIN user_category ON users.id = user_category.user_id WHERE user_category.category_id NOT IN (280, 210, 177, 207, 240, 157, 187, 246, 153, 208, 199, 156, 281, 211, 212, 220, 218, 170, 201, 222, 236, 233)
问题是,如果用户属于类别280并且也是我没有选择的类别之一,他们仍然会出现。
答案 0 :(得分:3)
Public Class Form1
Private DrawHighlightingRectangle As Boolean = True
Private HighlightingRectangleColour As Color = Color.Red
Private PenWidth = 1
Dim myPen As New System.Drawing.Pen(HighlightingRectangleColour, PenWidth)
Dim x = 0
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
Text = "Pen Width = " & PenWidth & ", X = " & x
myPen.Alignment = Drawing2D.PenAlignment.Inset
End Sub
Private Sub Form1_Paint(sender As Object, e As PaintEventArgs) Handles Me.Paint
If DrawHighlightingRectangle Then
e.Graphics.Clear(Me.BackColor)
e.Graphics.DrawLine(myPen, x, 100, x, 200)
e.Graphics.DrawLine(myPen, CInt(Math.Floor(PenWidth / 2)), 10, CInt(Math.Floor(PenWidth / 2)), 100)
End If
End Sub
Private Sub Form1_Resize(sender As Object, e As EventArgs) Handles Me.Resize
Me.Invalidate()
Me.Update()
End Sub
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click ' draw button
DrawHighlightingRectangle = Not DrawHighlightingRectangle
Me.Invalidate()
Me.Update()
End Sub
Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click ' Move Right
x += 1
Text = "Pen Width = " & PenWidth & ", X = " & x
Me.Invalidate()
Me.Update()
End Sub
Private Sub Button3_Click(sender As Object, e As EventArgs) Handles Button3.Click ' increase pen width
PenWidth += 1
myPen.Dispose()
myPen = New System.Drawing.Pen(HighlightingRectangleColour, PenWidth)
Text = "Pen Width = " & PenWidth & ", X = " & x
Me.Invalidate()
Me.Update()
End Sub
Private Sub Button4_Click(sender As Object, e As EventArgs) Handles Button4.Click ' reset width and X
PenWidth = 1
x = 0
myPen.Dispose()
myPen = New System.Drawing.Pen(HighlightingRectangleColour, PenWidth)
Text = "Pen Width = " & PenWidth & ", X = " & x
Me.Invalidate()
Me.Update()
End Sub
Private Sub Button5_Click(sender As Object, e As EventArgs) Handles Button5.Click ' Move Left
x -= 1
Text = "Pen Width = " & PenWidth & ", X = " & x
Me.Invalidate()
Me.Update()
End Sub
End Class