left String function in MySQLWe can specify the number of characters required from left side of a string by using left function in MySQL Let us start with an easy example
The output of this is here
Now we will apply this to our student table on name field
We will get left 5 chars of name field of student table.
Example : Taking out the userid part of email address.We can use LEFT function to get the userid part of the email address. Before that we will find out the position of @ char inside email address by using locate function. The output of locate function ( which gives the location of @ ) we will use to take the left most characters. Please note that there are several ways to solve this problem and this is one of the way only.
Let us first locate the position of @ in our email address.
This will give us a number for each record which we can use to get the userid part.
This will give us eserid part but will end with one extra @ added to it. Now here is the final one we can get by subtracting 1 from the output of locate function.
This article is written by plus2net.com team.