Subscribe ( )

iPhone Programming Tutorials


 

Forum

You must be logged in to post Login Register

Search 

grab a random row from a sqlite database

User Post

4:59 pm
September 24, 2008


envex

Noob

posts 5

1

Hey,

I am very new to the iphone sdk and Obj C, but i'm running through tutorials and starting to learn.

I have hit a bump in the road though, and i'm hoping someone could shed some lite on my problem.

I have a button, when the button is clicked i would like to open into a new view that grabs a random row from a sqlite database.

Is there somewhere on the net that would explain how to do this? I don't need it spelt out for me, something to just point me in the right direction.

Thanks,

envex

7:46 pm
September 24, 2008


iCoder

Sydney, Australia

posts 7

2

In terms of SQL, here's what I would do:

1. select the count of the rows in the table

2. use a random number generator to generate a number between 0 and the count retrieved above

3. use the LIMIT and OFFSET keywords on a SELECT statement to select the random row.

See regarding the SELECT statement.

8:23 pm
September 24, 2008


envex

Noob

posts 5

3

Hey,

Sorry, i wasn't exactly clear in my first post (my brain is being overloaded)

I'm pretty familiar with SQL from coding PHP all day.

I guess i could take a run through of the sqlite tutorial here, i was just worried it would point me in the wrong direction.

Any info is good info i guess!

Thanks for the response,

envex

Search 

About the iCodeBlog forum

Most Users Ever Online:

44


Currently Online:

4 Guests

Forum Stats:

Groups: 2

Forums: 6

Topics: 419

Posts: 893

Membership:

There are 934 Members

There has been 1 Guest

There are 2 Admins

There is 1 Moderator

Top Posters:

bobcubsfan – 54

crazyiez – 30

Uhu – 17

AdeC – 17

Nick – 15

jitesh61 – 12

Administrators: Brandon (88 Posts), Collin (0 Posts)

Moderators: VertigoSol (26 Posts)



©   

  • Posted by on 6 Aug 2008 in Uncategorized
  •   |  
  •   |  
  •   |  
  • Comments Off

Comments are closed.