Daniel
Daniel

Reputation: 285

SQL Query for string match in Obj-c

NSString *sql = [NSString stringWithFormat:@"SELECT * FROM %@ WHERE exposureNuclides = %@", table, sourceNuclides];

exposureNuclides is the correct column name, sourceNuclides logs the correct string. Yet there is no match and no returns. However, if I write it like;

NSString *sql = [NSString stringWithFormat:@"SELECT * FROM %@", table];

I get the full return as you'd expect. There is an issue between WHERE column_name = $string am I using the wrong comparison type by using = operator?

3 =     {
    exposureCiMins = "125.66";
    exposureDescription = "Man way Door";
    exposureNuclides = Ir192;
    id = 4;
};

as you can see, no trailing spaces.

Upvotes: 0

Views: 99

Answers (1)

fabulaspb
fabulaspb

Reputation: 1263

Add apostrophes to your SQL query

SELECT * FROM %@ WHERE exposureNuclides = '%@'

Upvotes: 1

Related Questions