Article Categories
- All Categories
-
Data Structure
-
Networking
-
RDBMS
-
Operating System
-
Java
-
MS Excel
-
iOS
-
HTML
-
CSS
-
Android
-
Python
-
C Programming
-
C++
-
C#
-
MongoDB
-
MySQL
-
Javascript
-
PHP
-
Economics & Finance
Selected Reading
MySQL query to display only 15 words from the left?
For this, use LEFT in MySQL. Let us first create a table −
mysql> create table DemoTable -> ( -> Title text -> ); Query OK, 0 rows affected (0.59 sec)
Insert some records in the table using insert command −
mysql> insert into DemoTable values('Java database connectivity to MySQL database');
Query OK, 1 row affected (0.12 sec)
mysql> insert into DemoTable values('Python with django framework');
Query OK, 1 row affected (0.11 sec)
mysql> insert into DemoTable values('C with data structure and algorithm');
Query OK, 1 row affected (0.33 sec)
Display all records from the table using select statement −
mysql> select *from DemoTable;
This will produce the following output −
+----------------------------------------------+ | Title | +----------------------------------------------+ | Java database connectivity to MySQL database | | Python with django framework | | C with data structure and algorithm | +----------------------------------------------+ 3 rows in set (0.00 sec)
Following is the query to display only 15 words from the left in MySQL −
mysql> select left(Title,15) as Title from DemoTable;
This will produce the following output:
+-----------------+ | Title | +-----------------+ | Java database c | | Python with dja | | C with data str | +-----------------+ 3 rows in set (0.00 sec)
Advertisements
