MySQL Query - Stupid question...

J

Jeff Miller

Hello,
Although I've dealt with many many SQL queries and whatnot, I actually
don't know how to return the number of rows it returned... I'm using the
MySQL gem and making my queries like this:

db1 = Mysql.connect("localhost", "root", "root", "project")
@new_entries = db1.query("SELECT * FROM new_entries")

...but what can I do to get the number of rows as well as the data from
the table?

Thanks,
- Jeff Miller
 
S

s.ross

Hello,
Although I've dealt with many many SQL queries and whatnot, I actually
don't know how to return the number of rows it returned... I'm using
the
MySQL gem and making my queries like this:

db1 = Mysql.connect("localhost", "root", "root", "project")
@new_entries = db1.query("SELECT * FROM new_entries")

...but what can I do to get the number of rows as well as the data
from
the table?

Thanks,
- Jeff Miller

@new_entries.num_rows
 
J

Jeff Miller

Thanks, that worked.

However, I'm doing another query in a different app using RoR... How can
I achieve the same thing? I want to get the number of rows off a query
such as this:

@grab_new_entries = NewEntries.connection.select_all("SELECT displayname
AS displayname FROM new_entries")

@grab_new_entries.num_rows didn't work....

Thanks,
- Jeff Miller
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,994
Messages
2,570,223
Members
46,814
Latest member
SpicetreeDigital

Latest Threads

Top