select * from (SELECT * FROM device0
               UNION ALL
               SELECT * FROM device1
               UNION ALL
               SELECT * FROM device2
               UNION ALL
               SELECT * FROM device3
               UNION ALL
               SELECT * FROM device4
               UNION ALL
               SELECT * FROM device5
               UNION ALL
               SELECT * FROM device6
               UNION ALL
               SELECT * FROM device7
               UNION ALL
               SELECT * FROM device8
               UNION ALL
               SELECT * FROM device9
               UNION ALL
               SELECT * FROM device10
               UNION ALL
               SELECT * FROM device11
               UNION ALL
               SELECT * FROM device12
               UNION ALL
               SELECT * FROM device13
               UNION ALL
               SELECT * FROM device14
               UNION ALL
               SELECT * FROM device15
               UNION ALL
               SELECT * FROM device16
               UNION ALL
               SELECT * FROM device17
               UNION ALL
               SELECT * FROM device18
               UNION ALL
               SELECT * FROM device19
               UNION ALL
               SELECT * FROM device20
               UNION ALL
               SELECT * FROM device21
               UNION ALL
               SELECT * FROM device22
               UNION ALL
               SELECT * FROM device23
               UNION ALL
               SELECT * FROM device24
               UNION ALL
               SELECT * FROM device25
               UNION ALL
               SELECT * FROM device26
               UNION ALL
               SELECT * FROM device27
               UNION ALL
               SELECT * FROM device28
               UNION ALL
               SELECT * FROM device29
               UNION ALL
               SELECT * FROM device30
               UNION ALL
               SELECT * FROM device31) t