Is it possible to use delete and count in a single statement?
My goal is to delete rows if artist has only 1 song
Here's my combined statement, doesn't work:
My goal is to delete rows if artist has only 1 song
B4X:
Dim ccU As Cursor = SQL.ExecQuery("SELECT * FROM forprintsingers")
Dim art as string
Dim progress as int
For i = 0 To ccU.RowCount-1
ccU.Position = i
If (i Mod 100) = 0 Then
Sleep(0)
progress = ((i / ccU.RowCount) * 100)
lblStatus.Text = progress & " %" &CRLF& "Please wait"
End If
art = ccU.GetString("name")
If SQL.ExecQuerySingleResult2("SELECT COUNT(*) FROM forprint WHERE artist = ?", Array As String(art)) = 1 Then
SQL.ExecNonQuery2("DELETE FROM forprint WHERE artist = ?", Array As Object(art))
End If
Next
Here's my combined statement, doesn't work:
B4X:
SQL.ExecNonQuery2("DELETE FROM forprint WHERE ((SELECT COUNT(*) FROM forprint WHERE artist = ?) = 1) AND artist = ?", Array As Object(art, art))