MySQL Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

Go Back   Dev Shed ForumsDatabasesMySQL Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old November 20th, 2012, 03:31 PM
lonenoel lonenoel is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Nov 2012
Posts: 1 lonenoel User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 47 m 14 sec
Reputation Power: 0
Splitting Text String in to column

Hi,

I am trying to pull some data from a column named shopsale_delivery in a table named shopsale the issue is that the text in this field is in a string with a new line delimiter ( \n ) and i require each new line to be captured in to different columns named as per the below

'addAddress1',
'addAddress2',
'addAddress3',
'addTown',
'addRegion',
'cPostCode'

just for your reference my previous sql was set up like this until i discovered the field i was referencing for the address columns was incorrect and that the whole address was in one column

SELECT
ss.shopsale_id as `orderId`,
ss.shopsale_delivery_cost as `fPostageCost`,
ss.shopsale_datetime as `dReceievedDate`,
concat( us.user_firstname,' ' ,us.user_lastname) as 'cFullName',
us.user_email as `cEmailAddress`,
ua.useraddress_postcode as 'cPostCode',
ss.shopsale_cost as `fTotalCharge`,
"" as `cCurrency`,
ss.shopsale_tax as 'fTax',
ua.useraddress_country as 'Country',
ss.shopsale_id as `ReferenceNum`,
ua.useraddress_1 as 'addAddress1',
ua.useraddress_2 as 'addAddress2',
'' as 'addAddress3',
ua.useraddress_city as 'addTown',
ua.useraddress_region as 'addRegion',
ua.useraddress_phone as 'CustomerPhoneNumber',
'' as 'addCompany',
'' as 'BillingCompany',
ua.useraddress_1 as 'BillingAddress1',
ua.useraddress_2 as 'BillingAddress2',
'' as 'Billingaddress3',
ua.useraddress_city as 'BillingTown',
ua.useraddress_Region as 'BillingRegion',
ua.useraddress_country as 'BillingCountry',
ua.useraddress_postcode as 'BillingPostcode',
'Default' as 'PaymentMethod'
FROM shopsale as ss
LEFT OUTER JOIN useraddress as ua
ON ss.shopsale_user_id = ua.useraddress_id
LEFT OUTER JOIN user as us
ON ss.shopsale_user_id = us.user_id
WHERE shopsale_status = 'PAID'
AND ua.useraddress_type = 'Delivery'

Hope someone can help me.

Thanks

Reply With Quote
  #2  
Old December 2nd, 2012, 06:03 AM
bobert123 bobert123 is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Mar 2012
Posts: 48 bobert123 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 9 h 17 m 2 sec
Reputation Power: 2
i think that an example is needed here to understand the format of your 'shopsale_delivery' column. i assume it's a text string, but what would an insert for that column look like?

Reply With Quote
Reply

Viewing: Dev Shed ForumsDatabasesMySQL Help > Splitting Text String in to column

Developer Shed Advertisers and Affiliates



Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap