mysql - Combine Two Select Statements Using UNION -


i learning sql statements, cannot see why code cannot execute database:

(select time mytable) union (select travel mytable); 

the above statement forbidden.

it not columns called time , travel of same datatype... when union 2 select statements, putting 2 values in same column. sql not know type make column. likely, sees time values, makes column datetime column, start trying cram travel varchar strings it.

try casting both same type, this:

select   date_format(time, '%y-%m-%d %h:%i:%s') time mytable  union  select   travel mytable; 

Comments

Popular posts from this blog

yii2 - Yii 2 Running a Cron in the basic template -

asp.net - 'System.Web.HttpContext' does not contain a definition for 'GetOwinContext' Mystery -

mercurial graft feature, can it copy? -