12/31/2023 0 Comments String split universal database![]() Because the first name starts in position one and ends at the location of the space minus one, we know the length of the first name is simply the location of the space minus one.Īt this point, we have three of the four pieces of information needed all that is missing is the length of the last name. We also know that the first name starts in position one. ![]() Knowing where the space is, we know that the first name ends one position before the space and the last name starts one position after the space. Knowing that our separator is a space, we will be searching for ' ' to break the fields apart. ![]() The LOCATE function finds the position of a string in a file. Hence, for this example, we must find four pieces of information: the starting position of the first name, the starting position of the last name, the length of the first name, and the length of the last name. To use SUBSTRING, we must pass in a starting position and a length. However, you can use a SELECT statement with SUBSTRING, LOCATE, and LENGTH to break apart each field. Because each name varies, there is no easy way to get just their first or last name out of this field. This contains a person's first name, a space, and their last name. However, if the lengths vary, this becomes more difficult.Īs an example, assume we have a file called MyLib/MyFile that has one field called FullName. If the data is uniform, a simple SUBSTRING can be used to break out the various parts. Sometimes more than one piece of information can be in a single field.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |