Select from multiple tables with UNION

I’ve trying to select records from 3 tables in one database with UNION but I’ve got error:

1248 – Every derived table must have its own alias

This is the query that I’m trying:

SELECT * from
  (SELECT column1, 'table1' from table1
   SELECT column1, 'table2'  from table2
   SELECT column1, 'table3'  from table3) 
WHERE column1 not like 'abr%' and length(column1) < 8;

What exactly mean that error and how can I fix it and show proper results?

Source: sql

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.