mysql - Query half of value -


how can query in phpmyadmin mysql db tabel column values first half of string (the values strings) contains given string? like:

select * `tabel` first_half_of_string(`column`) = %'search_for_string'%; 

you can use substring this.

select * `tabel`  substring(`column`, 1, length(`column`)/2) %'search_for_string'%; 

to handle , odd lengths of column, use

select * `tabel`  substring(`column`, 1, if(mod(length(`column`),2)=0, length(`column`)/2, 1+length(`column`)/2) %'search_for_string'%; 

Comments

Popular posts from this blog

routing - AngularJS State management ->load multiple states in one page -

python - GRASS parser() error -

post - imageshack API cURL -