union - How to add a row to the result of a SQL query with INNER JOIN? -


in times past, when need add row result of sql statement, write statement this:

select cola, colb my_table    union   select 'foo' cola, 'bar' colb; 

however, suppose i've written following sql:

select t1.cola, t1.colb, t2.colc my_table t1 inner join my_other_table t2 

how can add row my_table when inner joined table this?

update: wow, goofed. it's going-home time. forgot clause!

select t1.cola, t1.colb, t2.colc my_table t1 inner join my_other_table t2   on t1.colb = t2.colc 

select      (t1.cola, t1.colb my_table       union       select 'foo' cola, 'bar' colb) t1  inner join      my_other_table t2 on . . . 

Comments

Popular posts from this blog

php - What is the difference between $_SERVER['PATH_INFO'] and $_SERVER['ORIG_PATH_INFO']? -

fortran - Function return type mismatch -

queue - mq_receive: message too long -