sql - how to use like function in MySQL or run LIKE command in mysql when search need to more specific -
i want search in database how person have name 'i steven'
i want search on user table 3 column
firstname secondname lastname
i want sorting them first name match comes first secondname latter , lastname last when see result.
are command in mysql solve puzzle
select if (firstname 'i steven%', 4, if(secondname 'i steven%', 2, if (lastname 'i steven%', 1, 0) ) ) first_name_first user firstname 'i steven%' or secondname 'i steven%' or lastname 'i steven%' order first_name_first desc;
Comments
Post a Comment