Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

MySQL Select Query - Get only first 10 characters of a value

Tags:

sql

select

mysql

People also ask

How do I select the first 10 characters in SQL?

SQL Server LEFT() Function The LEFT() function extracts a number of characters from a string (starting from left).

How do I find the first 10 records in MySQL?

To select first 10 elements from a database using SQL ORDER BY clause with LIMIT 10. Insert some records in the table using insert command. Display all records from the table using select statement. Here is the alternate query to select first 10 elements.


Using the below line

SELECT LEFT(subject , 10) FROM tbl 

MySQL Doc.


SELECT SUBSTRING(subject, 1, 10) FROM tbl

Have a look at either Left or Substring if you need to chop it up even more.

Google and the MySQL docs are a good place to start - you'll usually not get such a warm response if you've not even tried to help yourself before asking a question.