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
Post a Comment