MySQL's Select command using Union clause
Posted on 2008-11-05
I would like to query two tables have the following columns
table_one: title, content
As you can see, the "table_two" doesn't have the title column. Without creating a "title" column, is it possible add a "dummy" column so the following query will work with the UNION clause?
select title as t, content as c from table_one
select dummy_title as t, content as c from table_one;
The reason is that I am trying to create a search feature in a PHP script that has "Blog", "News", "Comments" and other sections. So using the UNION clause I can combine the query but not all of them has the "title" field, for example "Comments", but I would also like to include "Comments" within the search.