Split MySQL String to two fieldsWhat is the difference between String and string in C#?How do I iterate over the words of a string?How do I read / convert an InputStream into a String in Java?Case insensitive 'Contains(string)'How do I split a string on a delimiter in Bash?How to replace all occurrences of a string in JavaScriptHow to check whether a string contains a substring in JavaScript?Does Python have a string 'contains' substring method?How to split a string in JavaWhy is char[] preferred over String for passwords?

Can Legal Documents Be Siged In Non-Standard Pen Colors?

Where did Edmond Malone place the Tempest in the chronology of Shakespeare's plays?

Are the IPv6 address space and IPv4 address space completely disjoint?

Are paving bricks differently sized for sand bedding vs mortar bedding?

Loading commands from file

What percentage of fillings performed today are done with mercury amalgam?

The IT department bottlenecks progress. How should I handle this?

New brakes for 90s road bike

How can I block email signup overlays or javascript popups in Safari?

When were female captains banned from Starfleet?

Rising and falling intonation

Why should universal income be universal?

Symbol used to indicate indivisibility

Did arcade monitors have same pixel aspect ratio as TV sets?

Why did the EU agree to delay the Brexit deadline?

How to explain what's wrong with this application of the chain rule?

Does the Location of Line-Dash-Wedge Notations Matter?

Lowest total scrabble score

A social experiment. What is the worst that can happen?

Creepy dinosaur pc game identification

What is Cash Advance APR?

What does routing an IP address mean?

Count the occurrence of each unique word in the file

How should I respond when I lied about my education and the company finds out through background check?



Split MySQL String to two fields


What is the difference between String and string in C#?How do I iterate over the words of a string?How do I read / convert an InputStream into a String in Java?Case insensitive 'Contains(string)'How do I split a string on a delimiter in Bash?How to replace all occurrences of a string in JavaScriptHow to check whether a string contains a substring in JavaScript?Does Python have a string 'contains' substring method?How to split a string in JavaWhy is char[] preferred over String for passwords?













-1















In short, I have a PHP form that asks for employee id, email and password to add the user to the DB which works fine.



The table in the DB also has Firstname and Lastname fields.



Because the powers that be feel asking for fname and lname in the form is a step too far, I wanted to split the employee id so that it populated at least the fname. Last name we're not overly bothered about as it isn't unique anyway.



In short, each employee id is made up of the same format, ie, first name followed by a number (ie John12345, Mark67890 (5 digits per employee id after the firstname)). I would like to insert into the DB the employee id, and whilst it's doing that, Split out at the first number (or last letter) and populate the firstname (the rest of the string split can be purged as long as the full employee id is inserted into the employee_id).



I've read that a split function is not available in MySQL so I'm trying to figure out the best way to achieve this.










share|improve this question


























    -1















    In short, I have a PHP form that asks for employee id, email and password to add the user to the DB which works fine.



    The table in the DB also has Firstname and Lastname fields.



    Because the powers that be feel asking for fname and lname in the form is a step too far, I wanted to split the employee id so that it populated at least the fname. Last name we're not overly bothered about as it isn't unique anyway.



    In short, each employee id is made up of the same format, ie, first name followed by a number (ie John12345, Mark67890 (5 digits per employee id after the firstname)). I would like to insert into the DB the employee id, and whilst it's doing that, Split out at the first number (or last letter) and populate the firstname (the rest of the string split can be purged as long as the full employee id is inserted into the employee_id).



    I've read that a split function is not available in MySQL so I'm trying to figure out the best way to achieve this.










    share|improve this question
























      -1












      -1








      -1








      In short, I have a PHP form that asks for employee id, email and password to add the user to the DB which works fine.



      The table in the DB also has Firstname and Lastname fields.



      Because the powers that be feel asking for fname and lname in the form is a step too far, I wanted to split the employee id so that it populated at least the fname. Last name we're not overly bothered about as it isn't unique anyway.



      In short, each employee id is made up of the same format, ie, first name followed by a number (ie John12345, Mark67890 (5 digits per employee id after the firstname)). I would like to insert into the DB the employee id, and whilst it's doing that, Split out at the first number (or last letter) and populate the firstname (the rest of the string split can be purged as long as the full employee id is inserted into the employee_id).



      I've read that a split function is not available in MySQL so I'm trying to figure out the best way to achieve this.










      share|improve this question














      In short, I have a PHP form that asks for employee id, email and password to add the user to the DB which works fine.



      The table in the DB also has Firstname and Lastname fields.



      Because the powers that be feel asking for fname and lname in the form is a step too far, I wanted to split the employee id so that it populated at least the fname. Last name we're not overly bothered about as it isn't unique anyway.



      In short, each employee id is made up of the same format, ie, first name followed by a number (ie John12345, Mark67890 (5 digits per employee id after the firstname)). I would like to insert into the DB the employee id, and whilst it's doing that, Split out at the first number (or last letter) and populate the firstname (the rest of the string split can be purged as long as the full employee id is inserted into the employee_id).



      I've read that a split function is not available in MySQL so I'm trying to figure out the best way to achieve this.







      mysql string split






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked 2 days ago









      Lucero79Lucero79

      1225




      1225






















          1 Answer
          1






          active

          oldest

          votes


















          0














          You must use Left and Right functions as follow:



          SET @employee = 'Employee12345';
          SELECT RIGHT(@employee ,5), LEFT(@employee, LENGTH(@employee)-5);


          Because employee number code is a 5 digit number, then you could use this code.
          If you wanna insert into another table, you must use INSERT INTO SELECT Statement as Follow:



          Insert into _newtable Select RIGHT(_employee ,5), LEFT(_employee, LENGTH(_employee)-5) FROM _oldtable;


          Where _employee is your oldtable field.






          share|improve this answer























          • ah ok, I see. The users are already in a table, so all I really want to do is run the query to split what is there into another column, rather than a new table, and the perfect world would be the submit from the PHP form would do the magic.

            – Lucero79
            2 days ago










          Your Answer






          StackExchange.ifUsing("editor", function ()
          StackExchange.using("externalEditor", function ()
          StackExchange.using("snippets", function ()
          StackExchange.snippets.init();
          );
          );
          , "code-snippets");

          StackExchange.ready(function()
          var channelOptions =
          tags: "".split(" "),
          id: "1"
          ;
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function()
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled)
          StackExchange.using("snippets", function()
          createEditor();
          );

          else
          createEditor();

          );

          function createEditor()
          StackExchange.prepareEditor(
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader:
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          ,
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          );



          );













          draft saved

          draft discarded


















          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55281205%2fsplit-mysql-string-to-two-fields%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown

























          1 Answer
          1






          active

          oldest

          votes








          1 Answer
          1






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes









          0














          You must use Left and Right functions as follow:



          SET @employee = 'Employee12345';
          SELECT RIGHT(@employee ,5), LEFT(@employee, LENGTH(@employee)-5);


          Because employee number code is a 5 digit number, then you could use this code.
          If you wanna insert into another table, you must use INSERT INTO SELECT Statement as Follow:



          Insert into _newtable Select RIGHT(_employee ,5), LEFT(_employee, LENGTH(_employee)-5) FROM _oldtable;


          Where _employee is your oldtable field.






          share|improve this answer























          • ah ok, I see. The users are already in a table, so all I really want to do is run the query to split what is there into another column, rather than a new table, and the perfect world would be the submit from the PHP form would do the magic.

            – Lucero79
            2 days ago















          0














          You must use Left and Right functions as follow:



          SET @employee = 'Employee12345';
          SELECT RIGHT(@employee ,5), LEFT(@employee, LENGTH(@employee)-5);


          Because employee number code is a 5 digit number, then you could use this code.
          If you wanna insert into another table, you must use INSERT INTO SELECT Statement as Follow:



          Insert into _newtable Select RIGHT(_employee ,5), LEFT(_employee, LENGTH(_employee)-5) FROM _oldtable;


          Where _employee is your oldtable field.






          share|improve this answer























          • ah ok, I see. The users are already in a table, so all I really want to do is run the query to split what is there into another column, rather than a new table, and the perfect world would be the submit from the PHP form would do the magic.

            – Lucero79
            2 days ago













          0












          0








          0







          You must use Left and Right functions as follow:



          SET @employee = 'Employee12345';
          SELECT RIGHT(@employee ,5), LEFT(@employee, LENGTH(@employee)-5);


          Because employee number code is a 5 digit number, then you could use this code.
          If you wanna insert into another table, you must use INSERT INTO SELECT Statement as Follow:



          Insert into _newtable Select RIGHT(_employee ,5), LEFT(_employee, LENGTH(_employee)-5) FROM _oldtable;


          Where _employee is your oldtable field.






          share|improve this answer













          You must use Left and Right functions as follow:



          SET @employee = 'Employee12345';
          SELECT RIGHT(@employee ,5), LEFT(@employee, LENGTH(@employee)-5);


          Because employee number code is a 5 digit number, then you could use this code.
          If you wanna insert into another table, you must use INSERT INTO SELECT Statement as Follow:



          Insert into _newtable Select RIGHT(_employee ,5), LEFT(_employee, LENGTH(_employee)-5) FROM _oldtable;


          Where _employee is your oldtable field.







          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered 2 days ago









          Nerio EspinaNerio Espina

          111




          111












          • ah ok, I see. The users are already in a table, so all I really want to do is run the query to split what is there into another column, rather than a new table, and the perfect world would be the submit from the PHP form would do the magic.

            – Lucero79
            2 days ago

















          • ah ok, I see. The users are already in a table, so all I really want to do is run the query to split what is there into another column, rather than a new table, and the perfect world would be the submit from the PHP form would do the magic.

            – Lucero79
            2 days ago
















          ah ok, I see. The users are already in a table, so all I really want to do is run the query to split what is there into another column, rather than a new table, and the perfect world would be the submit from the PHP form would do the magic.

          – Lucero79
          2 days ago





          ah ok, I see. The users are already in a table, so all I really want to do is run the query to split what is there into another column, rather than a new table, and the perfect world would be the submit from the PHP form would do the magic.

          – Lucero79
          2 days ago



















          draft saved

          draft discarded
















































          Thanks for contributing an answer to Stack Overflow!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid


          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.

          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55281205%2fsplit-mysql-string-to-two-fields%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          Kamusi Yaliyomo Aina za kamusi | Muundo wa kamusi | Faida za kamusi | Dhima ya picha katika kamusi | Marejeo | Tazama pia | Viungo vya nje | UrambazajiKuhusu kamusiGo-SwahiliWiki-KamusiKamusi ya Kiswahili na Kiingerezakuihariri na kuongeza habari

          SQL error code 1064 with creating Laravel foreign keysForeign key constraints: When to use ON UPDATE and ON DELETEDropping column with foreign key Laravel error: General error: 1025 Error on renameLaravel SQL Can't create tableLaravel Migration foreign key errorLaravel php artisan migrate:refresh giving a syntax errorSQLSTATE[42S01]: Base table or view already exists or Base table or view already exists: 1050 Tableerror in migrating laravel file to xampp serverSyntax error or access violation: 1064:syntax to use near 'unsigned not null, modelName varchar(191) not null, title varchar(191) not nLaravel cannot create new table field in mysqlLaravel 5.7:Last migration creates table but is not registered in the migration table

          은진 송씨 목차 역사 본관 분파 인물 조선 왕실과의 인척 관계 집성촌 항렬자 인구 같이 보기 각주 둘러보기 메뉴은진 송씨세종실록 149권, 지리지 충청도 공주목 은진현