[snip]
mysql> set @a:=0;
Query OK, 0 rows affected (0.00 sec)

mysql> select @a:[EMAIL PROTECTED],mod(@a,2),ordr_ID, poft_Sub_Month from 
er_poft 
group by 3,4 having mod(@a,2) = 0 limit 5;
+----------+-----------+---------+----------------+
| @a:[EMAIL PROTECTED] | mod(@a,2) | ordr_ID | poft_Sub_Month |
+----------+-----------+---------+----------------+
|        2 |         0 |    4323 | 01             |
|        4 |         0 |    4329 | 01             |
|        6 |         0 |    4332 | 01             |
|        8 |         0 |    4335 | 01             |
|       10 |         0 |    4344 | 01             |
+----------+-----------+---------+----------------+
5 rows in set (0.00 sec)
[/snip]

Now THIS is an elegant solution. The variable removes the need for an
auto-increment field. I can see that the group by might interfere with
the results if you are not careful, but using any unique identifier in
the record should work out well.


--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:    http://lists.mysql.com/[EMAIL PROTECTED]

Reply via email to