table1
ID
SUBJECT
CONTENT
table2
ID
SUBJECT
CONTENT
table3
ID
SUBJECT
CONTENT
... 5 more
I want to search SUBJECT
on all the tables
How can I do this?
table1
ID
SUBJECT
CONTENT
table2
ID
SUBJECT
CONTENT
table3
ID
SUBJECT
CONTENT
... 5 more
I want to search SUBJECT
on all the tables
How can I do this?
Because all the tables have the same syntax, you can use the UNION
operator.
SELECT * FROM Table1
UNION Table2
UNION Table3
UNION Table4
UNION Table5
UNION Table6
UNION Table7
UNION Table8
WHERE SUBJECT="Subject"
For the sake of simplicity, 8 tables isn't too much to write out. If you had more, I'd recommend a dynamic query.