I have two queries that I have to run, I cannon join them But their resultant tables have the same structrure.
我有两个必须运行的查询,我可以加入它们但是它们的结果表具有相同的结构。
For example 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.
PS这些只是我提供的示例,我有一个复杂的表结构。最重要的是我无法加入他们。
3 个解决方案
#1
31
select * from products where producttype=magazine
union
select * from products where producttype = book
#2
9
I think that magazin and book are varchar values and not columns in your table
我认为magazin和book是varchar值而不是表中的列
select * from products where producttype in ('magazine', 'book');
#3
7
Or, just a single query...
或者,只需一个查询......
select *
from products
where producttype = magazine
or producttype = book
#1
31
select * from products where producttype=magazine
union
select * from products where producttype = book
#2
9
I think that magazin and book are varchar values and not columns in your table
我认为magazin和book是varchar值而不是表中的列
select * from products where producttype in ('magazine', 'book');
#3
7
Or, just a single query...
或者,只需一个查询......
select *
from products
where producttype = magazine
or producttype = book