troubleshooting Question

MySQL - split column contents into 2 seperate columns

Avatar of sabecs
sabecs asked on
MySQL Server
2 Comments1 Solution169 ViewsLast Modified:
Is there a way to spilt `contact` column from my users table below into `First_Name` & `Last_Name`?

Basically want to find the first space in `contact` column and split first section into   `First_Name`  and remaining into `Last_Name` ?

CREATE TABLE IF NOT EXISTS `users2` (
  `id` int(6) NOT NULL AUTO_INCREMENT,
  `email` varchar(90) DEFAULT NULL,
  `contact` varchar(40) DEFAULT NULL,
  `First_Name` varchar(120) DEFAULT NULL,
  `Last_Name` varchar(120) DEFAULT NULL,
  `Phone` varchar(30) DEFAULT NULL,
  `comments` text,
  `Business_Name` varchar(150) DEFAULT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `id` (`id`)
) ENGINE=MyISAM  DEFAULT CHARSET=latin1 PACK_KEYS=0 AUTO_INCREMENT=1890 ;

--
-- Dumping data for table `users2`
--

INSERT INTO `users2` (`id`, `email`, `contact`, `First_Name`, `Last_Name`, `Phone`, `comments`, `Business_Name`) VALUES
(58, 'email2@gmail.com.au', 'Peter Testing', NULL, NULL, NULL, NULL, NULL),
(57, 'email4@gmail.com.au', 'Kathy Tristan', NULL, NULL, NULL, NULL, NULL),
(18, 'email5@gmail.com.au', 'Christoper Roberts', NULL, NULL, NULL, NULL, NULL);
ASKER CERTIFIED SOLUTION
Join our community to see this answer!
Unlock 1 Answer and 2 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 2 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros