Fix wrong table in SQL