Click here to Skip to main content
15,867,488 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more: , +
i create table orderSales, typeCustomer, Customer
i create view
SELECT [id]
,[OrderDate]
,[Total]
,[Pay]
,[Remain]
,[Sales]
,[ValueAdd]
,[CustomerType]
,[Name]
FROM [dbo].[vOrdersAll]
GO
but view Get 3 row only and table OrderSales has more than 3 row

What I have tried:

i create view
SELECT [id]
,[OrderDate]
,[Total]
,[Pay]
,[Remain]
,[Sales]
,[ValueAdd]
,[CustomerType]
,[Name]
FROM [dbo].[vOrdersAll]

view query
SELECT dbo.tbOrderSales.id, dbo.tbOrderSales.OrderDate, dbo.tbOrderSales.Total, dbo.tbOrderSales.Pay, dbo.tbOrderSales.Remain, dbo.tbOrderSales.Sales, dbo.tbOrderSales.ValueAdd, dbo.tblCustomerType.CustomerType,
dbo.tbCustomers.Name
FROM dbo.tbCustomers INNER JOIN
dbo.tblCustomerType ON dbo.tbCustomers.id = dbo.tblCustomerType.id INNER JOIN
dbo.tbOrderSales ON dbo.tbCustomers.Phone = dbo.tbOrderSales.Customers AND dbo.tblCustomerType.id = dbo.tbOrderSales.typeCustomer
Posted
Updated 17-Mar-23 6:29am

1 solution

Your view query uses two INNER JOINs - which only return rows with matching data in both tables. So the most likely thing is that the JOINs are causing the reduced data because some of the ON conditions aren't matching in both tables. for some rows.

Look at the other tables manually and check exactly what data you have, and what data you expect to be returned.
 
Share this answer
 
Comments
A Belal 17-Mar-23 12:33pm    
thanks more OriginalGriff , i need to return All Data and i need to learn how
OriginalGriff 17-Mar-23 12:54pm    
But we can't tell you how to do that as we have no access to your DB or any idea what the relationships between the tables might be!

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900