开发者

SQL Where Statement - Comparing to Instance Variable in C

开发者 https://www.devze.com 2023-02-18 20:58 出处:网络
Could anyone help me with the following WHERE statement ? I want to say \"Where Name is equal to name\".

Could anyone help me with the following WHERE statement ? I want to say "Where Name is equal to name".

NSString *query = [NSString stringWithFormat:@"SELECT Name, Description, Postcode, AddressLine1, ImageURL, 开发者_运维知识库Cost FROM MainDetails WHERE Name=@%", name];

Thanks in advance,

Martin


String values need to be quotes in SQL. So you need something like:

NSString *query = [... "... Name='@%'", name];

(assuming the rest of the syntax is valid, I don't know Objective-C)


Looks like you're missing the single quotes.

NSString *query = [NSString stringWithFormat:@"SELECT Name, Description, Postcode, AddressLine1, ImageURL, Cost FROM MainDetails WHERE Name='@%'", name];

0

精彩评论

暂无评论...
验证码 换一张
取 消