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

sublimetext3 - what keyboard shortcut is to comment/uncomment for this script tag in sublime -

java - No use of nillable="0" in SOAP Webservice -

ubuntu - Laravel 5.2 quickstart guide gives Not Found Error -