Sunday, 15 March 2015

mysql - SQL Select where found match value in column -



mysql - SQL Select where found match value in column -

is possible retrieval info mysql db match part of string without using "like"? illustration have column value of "22,56,79,45,69" , want retrieval rows number "45" ןs within column value without using "like" status ?

some thing this:

select * table_name 45 part of value in column_name

is possible or have utilize "like" ?

provided cannot alter schema, like operator easiest way this.

select * table_name column_name '45,%' -- starts 45 or column_name '%,45,%' -- 45 in middle somewhere or column_name '%,45' -- ends 45 or column_name = '45'; -- 45 item in list

you perhaps simplify as:

select * table_name concat(',',column_name,',') '%,45,%';

i recommend against approach if table big though, , performance concern. mysql won't able take advantage of index this. instead, i'd recommend normalizing data. set each value in separate row in different table, , join on table instead. considerably faster.

to reply actual question of whether or not possible current schema , without using like, check regexp operator. however, don't see beingness different using like. still have parse each string in table.

mysql sql

No comments:

Post a Comment