get first character mysql code example

Example 1: mysql get first x characters

SELECT LEFT(title , 10) FROM articles;

Example 2: mysql query first character

SELECT author FROM lyrics WHERE author LIKE 'B%';

Example 3: select first character of string mySql

mysql> SELECT pub_name, LEFT(pub_name, 5) 
    -> FROM publisher;
+------------------------------+-------------------+
| pub_name                     | LEFT(pub_name, 5) |
+------------------------------+-------------------+
| Jex Max Publication          | Jex M             | 
| BPP Publication              | BPP P             | 
| New Harrold Publication      | New H             | 
| Ultra Press Inc.             | Ultra             | 
| Mountain Publication         | Mount             | 
| Summer Night Publication     | Summe             | 
| Pieterson Grp. of Publishers | Piete             | 
| Novel Publisher Ltd.         | Novel             | 
+------------------------------+-------------------+
8 rows in set (0.00 sec)

Tags:

Sql Example