gosi123 gosi123 - 6 months ago 51
MySQL Question

Select left 4 characters

I have a database table name

. In that table, I have a column name
. In that month, I have few database values 201601, 201602, 201501 and 201502.

How do I write a sql query to select only those that starts with 2015?

From what I researched and tried, I am supposed to use a syntax called

This is what I tried:

SELECT month, LEFT(month, 4) FROM monthly;

What I know is that I am missing a
statement to tell that I want only

So how do I write this statement?


Assuming you want to get the entire column:

SELECT * FROM monthly WHERE month LIKE '2015%'