Better SQL select fixes the mouseclick savetodatabase bug

Signed-off-by: Alexander Skjolden <alex@plastboks.net>