SQL query to count rows of a table // R33
#3

NEVER use num_rows if the only thing you're intersted in is a count of something. You do not need to process the entire resultset (which could be thousands of records) if you only want one single number.
PHP код:
SELECT COUNT(*) FROM `mybb_users
That generates exactly one row with one column. Then retrieve that value like you would any other integer.

Quote:
Originally Posted by YouHack
Посмотреть сообщение
I'm using it to add +1 in UID ( user id ) for each registration...
I'm pretty sure the mybb database uses auto_increment, i.e. it generates the id automatically for each new insert.
Reply


Messages In This Thread
SQL query to count rows of a table // R33 - by YouHack - 12.04.2017, 22:00
Re: SQL query to count rows of a table // R33 - by GangstaSunny. - 12.04.2017, 22:37
Re: SQL query to count rows of a table // R33 - by Vince - 13.04.2017, 05:35
Re: SQL query to count rows of a table // R33 - by YouHack - 13.04.2017, 10:47
Re: SQL query to count rows of a table // R33 - by YouHack - 13.04.2017, 11:08

Forum Jump:


Users browsing this thread: 1 Guest(s)