Q:

Select from multiple tables in mysql

Is it possible directly in phpmyadmin in sql form to select from 10 tables at once? 
In my database I have 10 tables: table1, table2, ... table10. I have same column in them column1. Records in that column always starts like 123... and always is 12 symbols length.
What I want to do is to select from those tables records that doesn't start with 123 and they are <12 symbols length. 
Is it possible this? 

A:

The below query is what you're looking for    
SELECT * from
(SELECT column1, 'table1' table_name from table1
UNION ALL
SELECT column1, 'table2' table_name from table2
UNION ALL
... --repeat for all 10 tables
SELECT column1, 'table10' table_name from table10) 
where column1 not like '123%' and length(column1) < 12;

This will return results like this:
column1      table_name

abc          table2
1245yy       table5

This will give you all the records from each table where column1 does not conform to the conditions of length and format.
EDIT:
Many thanks to jarlh for this comment. Using UNION ALL in place of UNION is safe (and with performance boosts) because if the column1 happens to not have a unique index, then duplicate values coming from one table will be dropped. For some extra reading on the performance bonuses of using UNION ALL, check this link.

