Unknown column 'i' in 'where clause' SELECT typ,foreign_id FROM new_system WHERE system_id = i AND typ = 'kod'