goma smile Posted September 25, 2015 Report Share Posted September 25, 2015 Sveiki, ir 2 līdzīgi vārdi port un airport... iekš stringa.. Man vajadzētu ar kaut kādu vaicājumu kas apdeito ierakstus kur nosaukums ir tieši "port" vai tieši "airport" Ir kādi ieteikumi... ? Quote Link to comment Share on other sites More sharing options...
waplet Posted September 25, 2015 Report Share Posted September 25, 2015 WHERE vards = 'port' OR vards = 'airport' Quote Link to comment Share on other sites More sharing options...
goma smile Posted September 25, 2015 Author Report Share Posted September 25, 2015 es vairāk domāju ka ir: Astrakhan (Narimanovo Airport) (ASF)Tallinn Port Quote Link to comment Share on other sites More sharing options...
waplet Posted September 25, 2015 Report Share Posted September 25, 2015 where vards LIKE '%port%' Quote Link to comment Share on other sites More sharing options...
jurchiks Posted September 25, 2015 Report Share Posted September 25, 2015 (edited) waplet, r u srs? http://stackoverflow.com/a/6403154/540394 WHERE text REGEXP '[[:<:]]port[[:>:]]' -- \bport\b WHERE text REGEXP '[[:<:]]airport[[:>:]]' -- \bairport\b Case-insensitive ir defaultā: REGEXP is not case sensitive, except when used with binary strings. Edited September 25, 2015 by jurchiks Quote Link to comment Share on other sites More sharing options...
briedis Posted September 25, 2015 Report Share Posted September 25, 2015 jurhchik, dafak, kāpēc vajadzīgs kaut kāds regexs parastai LIKE % operācijai? :O Quote Link to comment Share on other sites More sharing options...
Kemito Posted September 25, 2015 Report Share Posted September 25, 2015 briedis - nederēs gadījumi kā "sport" vai "watport" "sssssport", "sairport", "portsss" vajag tiešus vārdus ("to the airport", "to the port", "so port is that way" etc.) līdz ar to like ar % nederēs. Quote Link to comment Share on other sites More sharing options...
briedis Posted September 25, 2015 Report Share Posted September 25, 2015 Nu tad vēl labāk - kāpēc nevar vienkārši ar OR? waplets uzvar, karoč. Quote Link to comment Share on other sites More sharing options...
Kemito Posted September 25, 2015 Report Share Posted September 25, 2015 Un ja vārds būs "hello port" tad to neņems vērā jo tas != "port". Viņam nepieciešams updeitot vērtības kas satur tieši vārdu port, tieši, lai neapdeito gadījumus, kad ir "hello sport", "hello ports" Kā to realizēsi ar OR vai LIKE? Quote Link to comment Share on other sites More sharing options...
briedis Posted September 25, 2015 Report Share Posted September 25, 2015 Labi, bļin: WHERE shit LIKE '% port%' OR LIKE '% airport% Quote Link to comment Share on other sites More sharing options...
Kemito Posted September 25, 2015 Report Share Posted September 25, 2015 airports, ports, portogrāfija, porteriino, porterikss, airportiņš, airportololololol - keisi būs included tad, šaubos, ka viņam tas der :( Quote Link to comment Share on other sites More sharing options...
briedis Posted September 25, 2015 Report Share Posted September 25, 2015 Labi, jurčika variants strādās. Labāk gan butu normāli izveidot atsevišķu kolonnu, kur glabāt tipu. Nez vai tas regex būs žiperīgs, kad ierakstu sāks palikt vairāk. Quote Link to comment Share on other sites More sharing options...
goma smile Posted September 25, 2015 Author Report Share Posted September 25, 2015 Paldies Juri ! sastapos ar vēlvienu variantu :D Astrakhan (Narimanovo Airport) (ASF) - LidostaTallinn Port - Osta un atradu 3 variantu : "Orlando international airport hotels" nezinu ko ar viņu darīt varētu sākumā izvilkt visas lidostas/ostas/ jaunā kollonā, un pēctam ar LIKE '%hotels%' lai izsijātu viņus kā hottels. un pēctam visu pārējo kas kur nebūs vārds keywordi / airport/port/hotel(s)/ uztaisīt uz "place" un problēma varētu būt atrisināta... Vēlreiz paldies :) Quote Link to comment Share on other sites More sharing options...
jurchiks Posted September 25, 2015 Report Share Posted September 25, 2015 (edited) alter table xyz add column `type` varchar(16) not null default 'other'; update xyz set `type` = 'port' WHERE text REGEXP '[[:<:]]port[[:>:]]' AND type = 'other'; update xyz set `type` = 'airport' WHERE text REGEXP '[[:<:]]airport[[:>:]]'AND type = 'other'; update xyz set `type` = 'hotel' WHERE text LIKE '%hotel%'AND type = 'other'; nu un tad paskaties, kam paliek type='other', un izdomā, varbūt tur vēl kādu tipu var uzlikt. Edited September 25, 2015 by jurchiks Quote Link to comment Share on other sites More sharing options...
kasisppr Posted September 29, 2015 Report Share Posted September 29, 2015 Ar Word boundaries ([[:<:]]port[[:>:]] MySQL vai "\bport\b" regexpā) ir viena īpatnība, kura iepējams šeit netraucēs. Tie atradīs arī hyphen ( - ) atdalītus vārdus Piemēram: Singe-port, military-airport. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.