Ask a Question related to PHP Notes, Design and Development.
-
didou@php.net #1
note 11895 deleted from function.mysql-result by didou
Note Submitter: [email]alec@brainpod.com[/email]
----
"select count(*) from users" will return a table with one row and one field whith the count of how many results the last select would have returned.
"select * from users" will return ALL the data from the rows that match this.
So using the second query followed by $mysql_num_rows to retrieve a count of rows is inefficient if you don't need the actual data but just the count. Keep this in mind. Following is an example of using the count function practically with MySQL:
select MONTHNAME(orderdate) as month, DAYOFMONTH(orderdate) as day, count(*) as volume from orders group by month,day;
might produce something like this for a quick tally of sales:
+-------+------+--------+
| month | day | volume |
+-------+------+--------+
| March | 7 | 4 |
| March | 8 | 13 |
| March | 9 | 10 |
| March | 10 | 4 |
| March | 11 | 1 |
| March | 12 | 1 |
+-------+------+--------+
6 rows in set (0.01 sec)
Alec Effrat
[email]alec@brainpod.com[/email]
didou@php.net Guest
-
note 18689 deleted from function.mysql-result by didou
Note Submitter: rob@clara.net ---- Dont forget you can always use count(*) with mysql_fetch_array() using good SQL querys.. $result =... -
note 26082 deleted from function.mysql-result by didou
Note Submitter: sedesignlinksnet ---- If you wish to select a field value in a SQL statement like: $sql = "SELECT uid FROM global_lookup... -
note 26738 deleted from function.mysql-result by didou
Note Submitter: fernando@unijui.tche.br ---- Here is one simple sample about how to use the mysql_result: <?php // Define the conexion... -
note 11074 deleted from function.mysql-result by didou
Note Submitter: squeezeboobies@digitalsorcery.net ---- If you have just performed an insert into a database with an auto incrementing field you... -
note 33639 deleted from function.mysql-connect by didou
Note Submitter: carp_a_dieum@yahoo.com ---- To extend amn -at- frognet.net comment. Here is a cool example of reusing mssql connections and...



Reply With Quote

