सिंटैक्स
select fullname, substring_index(fullname, ',', 1) as First_Name, substring_index(fullname, ',', -1) as Last_Name from yourTableName;
उदाहरण
mysql> create table demo79 (fullname varchar(50));
mysql> insert into demo79 values('John,Smith'), ('David,Miller'), ('Chris,Brown');
परिणाम
+--------------+------------+-----------+ | fullname | First_Name | Last_Name | +--------------+------------+-----------+ | John,Smith | John | Smith | | David,Miller | David | Miller | | Chris,Brown | Chris | Brown | +--------------+------------+-----------+
count=1: पहला कॉमा से पहले (पहला नाम)।count=-1: अंतिम कॉमा के बाद (अंतिम नाम)।
सीमा: एक से अधिक कॉमा होने पर केवल पहला/अंतिम भाग मिलता है।