

- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Fetch some words from the left in MySQL
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 fetch some words from the left in MySQL −
mysql> select left(Title,10) as Title from DemoTable;
This will produce the following output −
+-----------------+ | Title | +-----------------+ | Java datab | | Python wit | | C with dat | +-----------------+ 3 rows in set (0.00 sec)
- Related Questions & Answers
- MySQL query to display only 15 words from the left?
- MySQL select statement to fetch 5 characters from the left of the string
- Fetch only capital words from DataFrame in Pandas
- Fetch substrings from a string with words separated by slash in MySQL?
- Fetch the maximum value from a MySQL column?
- How to order records and fetch some using MySQL LIMIT?
- How to write PHP script to fetch data, based on some conditions, from MySQL table?
- How to use MySQL SELECT LEFT to fetch the records containing string with slash
- MySQL RegExp to fetch records with only a specific number of words
- Fetch random rows from a table with MySQL
- Fetch similar ID records from two tables in MySQL
- Fetch records from comma separated values using MySQL IN()?
- MySQL query to exclude some of the values from the table
- Want to fetch only the month part from a date in MySQL
- How to fetch the newly added records from a MySQL table?
Advertisements