mysql match first characters code example

Example 1: mysql query first character

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

Example 2: 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