0
I’m trying to do the SELECT
below passing a value as parameter in the query, only it keeps giving the same error.
android.database.sqlite.Sqliteexception: near "SQL": syntax error (code 1): , while compiling: SQL * FROM Employers WHERE id = ?
What’s wrong with mine SELECT
?
public Employer getEmployerProfile(String parameter) {
String sql = "SQL * FROM Employers WHERE id = ?";
SQLiteDatabase db = getReadableDatabase();
Cursor c = db.rawQuery(sql, new String[]{parameter});
c.moveToFirst();
Employer employerProfile = new Employer();
employerProfile.setName(c.getString(c.getColumnIndex("name")));
employerProfile.setAddress(c.getString(c.getColumnIndex("address")));
return employerProfile;
}
Format of fields in table:
private String createTableEmployers() {
String sql = "CREATE TABLE Employers (id INTEGER PRIMARY KEY, name TEXT NOT NULL, email TEXT NOT NULL, address TEXT, status TEXT, confirmationStatus TEXT)";
return sql;
}
Thank you, it was lack of attention anyway. I think I was already addicted to the error. How can I simplify the code?
– Markus Branco