开发者

Append Results from two queries and output as a single table

I have two queries that I have to run, I cannon join them But their resultant tables have the same structrure.

For exa开发者_开发知识库mple I have

select * from products where producttype=magazine

select * from products where producttype = book

I have to combine the result of these two queries, and then output it as one single result. I have to do this inside a stored procedure.

PS These are just examples I provided, i have a complex table structure. The main thing is I cannot join them.


select * from products where producttype=magazine
union
select * from products where producttype = book


I think that magazin and book are varchar values and not columns in your table

select * from products where producttype in ('magazine', 'book');


Or, just a single query...

select *  
   from products 
   where producttype = magazine
      or producttype = book 
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜