This is the new home of the egghelp.org community forum.
All data has been migrated (including user logins/passwords) to a new phpBB version.


For more information, see this announcement post. Click the X in the top right-corner of this box to dismiss this message.

mysql search count

Help for those learning Tcl or writing their own scripts.
Post Reply
h
heman
Voice
Posts: 13
Joined: Sat Dec 30, 2006 3:17 pm

mysql search count

Post by heman »

If I search someting in the mysql db, after the results it shows someting like:
1 row in set (0.07 sec)
Is there a way to use that info, so it can be announced in the irc channel?

What i am looking for is the count of the result that it found and show that in the channel.

I al ready tried it with:

Code: Select all

select count(*) from $table WHERE search like '%$search%';
That works, but if the search is in the db a lot, it is slow.
So I thougth way do I need this code if its already shown after the search is done.

Is this possible? Or maybe some1 else know a better and faster way?

thanks
d
dwickie
Halfop
Posts: 76
Joined: Sat Aug 21, 2004 8:53 am
Location: /pub/beer

Re: mysql search count

Post by dwickie »

heman wrote:If I search someting in the mysql db, after the results it shows someting like:
1 row in set (0.07 sec)
Is there a way to use that info, so it can be announced in the irc channel?

What i am looking for is the count of the result that it found and show that in the channel.

I al ready tried it with:

Code: Select all

select count(*) from $table WHERE search like '%$search%';
That works, but if the search is in the db a lot, it is slow.
So I thougth way do I need this code if its already shown after the search is done.

Is this possible? Or maybe some1 else know a better and faster way?

thanks
for example: use SELECT (with rows, not count(*)) and then SELECT FOUND_ROWS() below to see number of matches. there is more ways how to do that, if i got correctly what you want to do
Post Reply