fixed sql bug

Signed-off-by: Karl Merkli <info@karl-merkli.ch>