Search code examples
iossqlobjective-csqlitefmdb

SELECT from VIEW with FMDB


I have an SQLite database with the following tables:

  • Player
  • Card
  • Team
  • PlayerCard

CardDataComposed is a VIEW created with the following SELECT:

SELECT Player.PlayerID, Player.PlayerFirstName, Player.PlayerLastName, Card.CardID, Team.TeamID, Team.TeamName

FROM Player, Card, PlayerCard, Team 
WHERE Player.PlayerID=PlayerCard.PlayerID
AND Card.CardID=PlayerCard.CardID 
AND Team.TeamID=PlayerCard.TeamID;

Using the sqlite3 command line tool, SELECT * FROM CardDataComposed returns all of the records. However using the same query with FMDB:

NSString *dbQuery = @"SELECT * FROM CardDataComposed";
[self.database executeQuery:dbQuery];

Does not return any records. I imagine it has to do with how I'm (incorrectly) putting together the query so that FMDB can retrieve the records properly. How do I fix my query to select records from this view? Am I able to query views from FMDB? Thanks in advance!


Solution

  • I had to delete the contents of the Documents directory in my Simulator to see the changes I made to the database. The above query works as expected.