Fix incorrect logic order in sql query
Fix incorrect logic order in sql query

The previous order caused problems with two identical databases
(say production and development)

NitroXy/BasicObject,NitroXy/BasicObject,edruid/BasicObject