SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 General SQL Server Forums
 New to SQL Server Administration
 Extracting data
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

Calleman87
Starting Member

Sweden
2 Posts

Posted - 08/22/2014 :  07:23:39  Show Profile  Reply with Quote
Hi all!

New to all this SQL-thing. I'm running a joint company with a friend of mine and we are trying to extract a bunch of data from our tables.
I've managde to retrieve the data that we want out of an order table, but I can't make it export the way I want.

We have two tables with information that we want to extract.

The code we've written looks like this:

"SELECT o.id_order, o.reference, o.id_customer, o.payment, od.id_order_detail
FROM ps_orders o
LEFT JOIN ps_order_detail od ON (od.id_order = o.id_order)"

It gives us a result that looks like this:
8 12345 78 PayPal ProductName
8 12345 78 PayPal ProductName
8 12345 78 PayPal ProductName
9 12789 60 PayPal ProductName
9 12789 60 PayPal ProductName
9 12789 60 PayPal ProductName

So extracting the data is not an issue (from what I feel) I would like it to be:

8 12345 78 Paypal
ProductName
ProductName
ProductName
9 12789 60 PayPal
ProductName
ProductName
ProductName

What code would you recommend me to use to export the data in the format written above?

Thank you in advance!

tkizer
Almighty SQL Goddess

USA
37133 Posts

Posted - 08/22/2014 :  12:25:37  Show Profile  Visit tkizer's Homepage  Reply with Quote
This should be handled by the application layer, whether it be your program or a report. Return raw data from SQL, and let the application layer handle the formatting.

Tara Kizer
SQL Server MVP since 2007
http://weblogs.sqlteam.com/tarad/
Go to Top of Page

Calleman87
Starting Member

Sweden
2 Posts

Posted - 08/22/2014 :  13:32:30  Show Profile  Reply with Quote
Hi Tara!

Thanks for replying! I'm not really sure what you mean by application layer, but I'm taking a wild guess here, (after all, as an accountant by trade, I must be forgiven, right? ;)) the application which will be used to import into is of strict format. The manufacturer of the program clearly specifies that an import .csv file should be arranged in a certain order, otherwhise the import will fail. Hence the need to extract data from database and present it in a certain order. What i'm asking about is non-achievable?
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.05 seconds. Powered By: Snitz Forums 2000