MySQL's Select command using Union clause

I would like to query two tables have the following columns

table_one: title, content
table_two: 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
union
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.

Thank you.
santockiAsked:
Who is Participating?
 
Guy Hengel [angelIII / a3]Connect With a Mentor Billing EngineerCommented:
yes:

select title as t, content as c from table_one
union
select null as t, content as c from table_one;

Open in new window

0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.