There is a MySQL table named stat:
line_name device_name count
1001 3548001 2
1002 3548002 3
1003 3548003 6
2001 3548004 7
2002 3548005 3
2003 3548006 4
3001 3548007 3
3002 3548008 9
3003 3548009 7
I need to select 2 records where the first char in line_name
is different
For example:
1001 3548001 2
3003 3548009 7
or:
2002 3548005 3
3001 3548007 3
I tried this:
SELECT DISTINCT(SUBSTRING(line_name,1,LENGTH(line_name)-3)) as pack_id, device_name, count
from stat
order by rand()
limit 2;
but from time to time I get the same pack_id
in the result set