1//number of rows retrieved from a query
2<?php
3
4$link = mysql_connect("localhost", "mysql_user", "mysql_password");
5mysql_select_db("database", $link);
6
7$result = mysql_query("SELECT * FROM table1", $link);
8$num_rows = mysql_num_rows($result);
9
10echo "$num_rows Rows\n";
11
12?>
13
14
1SELECT row_number() over ( order by firstName) RowNumberSqeuence,FirstName from rowNumberDemo
2 order by FirstName;
1
2
3
4
5 set @row_number := 0;
6
7SELECT
8 @row_number:=CASE
9 WHEN @customer_no = customerNumber
10 THEN @row_number + 1
11 ELSE 1
12 END AS num,
13 @customer_no:=customerNumber customerNumber,
14 paymentDate,
15 amount
16FROM
17 payments
18ORDER BY customerNumber;
1SET @row_number = 0;
2SELECT
3 (@row_number:=@row_number + 1) AS num,
4 firstName,
5 lastName
6FROM
7 employees
8ORDER BY firstName, lastName
9LIMIT 5;