- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- MS Excel
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP
- Physics
- Chemistry
- Biology
- Mathematics
- English
- Economics
- Psychology
- Social Studies
- Fashion Studies
- Legal Studies
- 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)
Advertisements