LittleSampson Posted December 14, 2003 Posted December 14, 2003 I looked at the article from the ASP Kick Start "Displaying Rows Grouped by Category", but I am new to .net and can't make the connection for my duplicates in a datagrid. When I add a template column, the code is different than is demostrated in the example. I am using a stored procedure to select Customers; Customers, Phone numbers and PhoneTypes(fax, Cell, Office) are stored in separate tables. I DON'T want the data displayed in a list, it needs to be displayed in a row. EX: Customer Fax_Number Cell_Number Office_Number Cust1 111-111-1111 222-222-2222 333-333-3333 As it is set up now when I run the search for customer I get Customer Phontype Phone Number Cust1 fax 111-111-1111 Cust1 Office 222-222-2222 Cust1 Cell 333-333-3333 Quote
kahlua001 Posted December 16, 2003 Posted December 16, 2003 SELECT Customers.Name, Fax.Number, Cell.Number, Office.Number FROM Customers INNER JOIN FAX ON Customers.CustomerID = Fax.CustomerID INNER JOIN Cell ON Customers.CustomeriD = Cell.CustomerID Inner JOIN Office ON Customers.CustomerID = Office.CustomerID Or something like that... Quote
LittleSampson Posted December 16, 2003 Author Posted December 16, 2003 My SQL statement My select statement is Select Customer from Customers As C Join CustomerPhone As CP on C.CustID = CP.Cust ID Join Phone AS P on CP.CustID = P.CustID Join PhoneTypes As PT on P.PhoneTypeID = PT.PhoneTypeID Where CustID = @CustID This will select the customer from the customer table, the numbers from the PhoneNumbers table and the type of number (fax, Business, Cell) from the PhoneTypes table. Quote
kahlua001 Posted December 16, 2003 Posted December 16, 2003 Try joining the Phone table 3 times onto the Customer table, pick the appropriate join depending on if you know that number will exist for each customer. Untested exampe.. SELECT Customer.Name, Phone1.Number As OFFICE, Phone2.Number As CELL FROM Customers INNER JOIN Phone Phone1 ON Customers.CustID = Phone1.CustID INNER JOIN Phone Phone2 ON Customers.CustID = Phone2.CustID WHERE Phone1.PhoneTYpe = 'OFFICE' AND Phone2.PhoneType = 'CELL' Not sure if that will work without playing around with it some more, but you can give it a try. Quote
Muhad Posted December 18, 2003 Posted December 18, 2003 Use could try using 'Select Distinct blah,blah,blah'. Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.