Note that there are some explanatory texts on larger screens.

plurals
  1. POsqlite xcode query clause
    primarykey
    data
    text
    <p>i have some strange problem with my query on sqlite. When i have values for the firstvar between 30000 and 100000 my query doesn't return anything. but when the var is lower than 30000 and bigger than 100000 it does. it's the same in my xcode app as in sqlite browser. </p> <pre><code>SELECT * FROM OFFERS WHERE price &gt; firstvar AND price &lt; secondvar </code></pre> <p>here is some example data: <a href="http://www.purespain.com/example%20data.png" rel="nofollow">http://www.purespain.com/example%20data.png</a> </p> <p>so when i perform the query for example</p> <pre><code> SELECT * FROM OFFERS WHERE price &gt; 40000 AND price &lt; 300000 </code></pre> <p>i have no ouput while there are a lot of offers with a price (prijs) that should match the criteria.</p> <p>when i perform for example</p> <pre><code> SELECT * FROM OFFERS WHERE price &gt; 140000 AND price &lt; 300000 </code></pre> <p>or SELECT * FROM OFFERS WHERE price > 0 AND price &lt; 300000</p> <p>then i have correct results</p> <p>the code for executing the query is: </p> <pre><code>-(NSMutableArray *)selectOffersWithOndergrens:(int)ondergrens andBovengrens:(int)bovengrens andSoort:(NSString *)soort{ NSArray *path = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask , YES); NSString *docpath = [path objectAtIndex:0]; dbPathString = [docpath stringByAppendingPathComponent:@"puurspanje.db"]; Offers = [[NSMutableArray alloc] init]; // Get all newsitems from the sqlite database sqlite3_stmt *get_offers_stmt; NSString *querysql = [[NSString alloc]init]; if (sqlite3_open([dbPathString UTF8String], &amp;puurspanjeDB)==SQLITE_OK){ [Offers removeAllObjects]; if (![soort isEqual: @"alle"]){ querysql = [NSString stringWithFormat:@"SELECT * FROM OFFERS WHERE prijs &gt; %d AND prijs &lt; %d AND soort = (SELECT TYPE_ID FROM TYPES WHERE NAME LIKE '%@' )", ondergrens, bovengrens, soort]; }else{ querysql = [NSString stringWithFormat:@"SELECT * FROM OFFERS WHERE prijs &gt; %d AND prijs &lt; %d", ondergrens, bovengrens]; } const char* query_sql = [querysql UTF8String]; if (sqlite3_prepare(puurspanjeDB, query_sql, -1, &amp;get_offers_stmt, NULL)==SQLITE_OK) { while (sqlite3_step(get_offers_stmt)==SQLITE_ROW) { NSString *listing_ID = [[NSString alloc]initWithUTF8String:(const char *) sqlite3_column_text(get_offers_stmt, 1)]; NSString *titel = [[NSString alloc]initWithUTF8String:(const char * )sqlite3_column_text(get_offers_stmt, 2)]; NSString *omschrijving = [[NSString alloc]initWithUTF8String:(const char * )sqlite3_column_text(get_offers_stmt, 3)]; NSString *prijs = [[NSString alloc]initWithUTF8String:(const char * )sqlite3_column_text(get_offers_stmt, 4)]; NSString *referentie = [[NSString alloc]initWithUTF8String:(const char*)sqlite3_column_text(get_offers_stmt, 5)]; NSString *slaapkamer = [[NSString alloc]initWithUTF8String:(const char*)sqlite3_column_text(get_offers_stmt, 6)]; NSString *verdiep = [[NSString alloc]initWithUTF8String:(const char*)sqlite3_column_text(get_offers_stmt, 7)]; NSString *badkamers = [[NSString alloc]initWithUTF8String:(const char*)sqlite3_column_text(get_offers_stmt, 8)]; NSString *woonoppv = [[NSString alloc]initWithUTF8String:(const char*)sqlite3_column_text(get_offers_stmt, 9)]; NSString *perceeloppv = [[NSString alloc]initWithUTF8String:(const char*)sqlite3_column_text(get_offers_stmt, 10)]; NSString *kenmerken = [[NSString alloc]initWithUTF8String:(const char*)sqlite3_column_text(get_offers_stmt, 11)]; NSString *buurtkenmerken = [[NSString alloc]initWithUTF8String:(const char*)sqlite3_column_text(get_offers_stmt, 12)]; NSString *indeling = [[NSString alloc]initWithUTF8String:(const char*)sqlite3_column_text(get_offers_stmt, 13)]; NSString *hypotheek = [[NSString alloc]initWithUTF8String:(const char*)sqlite3_column_text(get_offers_stmt, 14)]; NSString *soort = [[NSString alloc]initWithUTF8String:(const char*)sqlite3_column_text(get_offers_stmt, 15)]; Offer *offer = [[Offer alloc]initWithListing_ID:listing_ID andTitel:titel andOmschrijving:omschrijving andPrijs:prijs andReferentie:referentie andSlaapkamers:slaapkamer andVerdiep:verdiep andBadkamers:badkamers andWoonoppv:woonoppv andPerceeloppv:perceeloppv andKenmerken:kenmerken andBuurtKenmerken:buurtkenmerken andIndeling:indeling andHypotheek:hypotheek andSoort:soort]; [Offers addObject:offer]; } } } return Offers; </code></pre> <p>}</p> <p>I have no idea what the reason could be. Any help is appreciated. </p> <p>Jonas</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload