I have a sql file which has a lot of insert statements (over 3000+). E.g.
insert into `pubs_for_client` (`ID`, `num`, `pub_name`, `pub_address`, `publ_tele`, `publ_fax`, `pub_email`, `publ_website`, `pub_vat`, `publ_last_year`, `titles_on_backlist`, `Personnel`) values('7','5','4TH xxxx xxxx','xxxx xxxx, 16 xxxxx xxxxx, xxxxxxx, We','111111111','1111111111','support@example.net','www.example.net','15 675 4238 14',NULL,NULL,'Jane Bloggs(Sales Contact:)jane.bloggs@example.net,Joe Bloggs(Other Contact:)joe.bloggs@example.net');
I have exported this into an excel document (I did this through running the query in phpmyadmin, and exporting for an excel document). There's just one problem, as you can see in this case, there are two names & email addresses being inserted into 'Personnel'.
How easy/difficult would it be to seperate these out to display as Name, email, Name2, email2?
What about when there are three e-mails/names? With shown data it should be easy to do
The above will split the Personnel column on delimiter
,
.You can then split these fields on delimiter
(
and)
to split personnel into name, position and e-mailThe SQL will be ugly (because mysql does not have split function), but it will get the job done.
The split expression was taken from comments on mysql documentation (search for split).
You can also
After which you can user
You could also create your own function that will extract directly names and e-mails.
As bogeymin has already said - either get the data to CSV (or convert it easily from Excel) to manipulate it. If you're on Windows, then have a look at using Notepad++ to break apart the last column.
Or... (and I'd probably do this), insert it into the database as it is (even if you insert into a dummy field, not the one you eventually want to use), then use the string manipulation functions in your varient of SQL to make either update statements, or more insert statements (whatever you need). Cerainly, MS-SQL Server can do this using things like SUBSTRING, PATINDEX etc etc...