我提出两个选择语句与不同的结果集, 请帮我做这两个SELECT语句显示其结果在一个表中,SQL Server中,如何创建一个表中的两个select语句
DECLARE @EmpID INT
SELECT @EmpID = SubCategoryId
FROM dbo.Product
WHERE ProductId = 13
SELECT Product.ProductId
, Product.ProductName
, Product.ProductPrice
, Product.ProductQuantity
, Product.SubCategoryId AS ForUpdate
, SubCategory.SubCategoryName
, SubCategory.SubCategoryId
FROM Product
INNER JOIN ProductUnderCategory
ON ProductUnderCategory.ProductId = Product.ProductId
INNER JOIN SubCategory
ON ProductUnderCategory.SubCategoryId = SubCategory.SubCategoryId
WHERE Product.ProductId = 13
SELECT Property.Propertyid
, Property.PropertyName
, ProductProperties.PropertyValue
FROM Property
LEFT JOIN ProductProperties
ON Property.PropertyId = ProductProperties.PropertyId AND ProductProperties.ProductId = 13
WHERE Property.Propertyid IN (
SELECT PropertyId
FROM CategoryProperty
WHERE CategoryProperty.SubCategoryId = CategoryProperty.SubCategoryId AND CategoryProperty.SubCategoryId = @EmpID
)
您是使用mySQL还是MS SQL Server?你有两个标签。 – Morpheus
你想合并来自两个结果集的所有行吗?如果是这样,列将需要“排队”,并且没有相同数量的列被返回。 – Morpheus
如果这是SQL Server(我不知道关于mysql),那么你将需要一个联盟,但作为Morpheus说这两个查询的列需要匹配。 – OldBoyCoder