pilots Posted February 3, 2008 Report Share Posted February 3, 2008 (edited) Aptuveni 3000 ieraksti datubāzē kuros vienā laukā vajag izdzēst konkrētas frāzes. Vai to var izdarīt ar kādu mysql vaicājumu? Kā Jūs ieteiktu to risināt? EDIT. Piemēra situācija db: id | info | teksts 1 | test | Mani sauc Jēkabs 2 | test | Mani sauc Juris 3 | test | Mani sauc Laimonis 4 | test | Mani sauc Didzis 5 | test | Mani sauc Ēriks ... utt ... Nepieciešams izdzēst "Mani sauc " no visiem datubāzes ierakstiem. Edited February 3, 2008 by pilots Link to comment Share on other sites More sharing options...
Gints Plivna Posted February 3, 2008 Report Share Posted February 3, 2008 Apmēram tā UPDATE <table> SET <kolona> = REPLACE(<kolona>, 'konkrētā frāze', '') WHERE <kolona> LIKE '%konkrētā frāze%' Gints Plivna http://datubazes.wordpress.com Link to comment Share on other sites More sharing options...
pilots Posted February 3, 2008 Author Report Share Posted February 3, 2008 Apmēram? ;) Nu ok, riskēšu. Link to comment Share on other sites More sharing options...
Gints Plivna Posted February 3, 2008 Report Share Posted February 3, 2008 Nepieciešams izdzēst "Mani sauc " no visiem datubāzes ierakstiem. Ja kā izrādās visas frāzes ir sākumā, tad substring f-ja arī strādātu, vienkārši nogriežam sākumu nost. Link to comment Share on other sites More sharing options...
Gints Plivna Posted February 3, 2008 Report Share Posted February 3, 2008 Apmēram? ;) Nu ok, riskēšu. Jebkas, kas tiek atrasts internetā un par ko nav skaidrības kā tas strādā un ticības, ka tas ir OK, ir vispirms jānotestē :) Link to comment Share on other sites More sharing options...
pilots Posted February 3, 2008 Author Report Share Posted February 3, 2008 Viss nostrādāja ideāli! Paldies, Gint! Link to comment Share on other sites More sharing options...
Paulinjsh Posted February 4, 2008 Report Share Posted February 4, 2008 īsti vīri backup netaisa :> Link to comment Share on other sites More sharing options...
7924 Posted February 7, 2008 Report Share Posted February 7, 2008 mazliet paturpināšu tēmu. man vajag, lai tabulas laukos, kuros ir vārds 'Didzis' tiktu papildināts ar vārdiem- "Es esmu laimīgs, ka ": id | info | teksts 1 | test | Mani sauc Jēkabs 2 | test | Mani sauc Juris 3 | test | Mani sauc Laimonis 4 | test | Es esmu laimīgs, ka Mani sauc Didzis 5 | test | Mani sauc Ēriks kā tas izdarāms, jo ar vienkārši reilpeisošanu te nesanāks? Link to comment Share on other sites More sharing options...
cucumber Posted February 7, 2008 Report Share Posted February 7, 2008 (edited) nevar kaut ko tadu update SET teksts = concat('Es esmu laimīgs, ka', teksts) WHERE teksts LIKE %Didzis%. ps. paskaties ka contcat syntakse pareizi rakstas Edited February 7, 2008 by cucumber Link to comment Share on other sites More sharing options...
7924 Posted February 7, 2008 Report Share Posted February 7, 2008 cucumber, paldies, tas kas vajadzīgs :) Link to comment Share on other sites More sharing options...
7924 Posted February 7, 2008 Report Share Posted February 7, 2008 (edited) vel jautājums, kā lai procedūrai vērtību raksta aiz LIKE DELIMITER $$ DROP PROCEDURE IF EXISTS `test`.`tabulas_update`$$ CREATE DEFINER=`root`@`localhost` PROCEDURE `tabulas_update`(IN pieliekama_value TINYTEXT, IN saturosa_value TINYTEXT) BEGIN UPDATE tb_options SET option_name = concat(pieliekama_value, option_name) WHERE option_name LIKE saturosa_value; END$$ DELIMITER; es gribu procedūrai padodamo vērtību ielikt šādi: LIKE %saturosa_value% - bet tā viņam nepatīk; kad lieku šādi: LIKE '%saturosa_value%' tad vins to vairs neaprot par mainīgo; kā būt? Edited February 8, 2008 by 7924 Link to comment Share on other sites More sharing options...
andrisp Posted February 7, 2008 Report Share Posted February 7, 2008 Moška CONCAT arī tur ? Link to comment Share on other sites More sharing options...
Aleksejs Posted February 7, 2008 Report Share Posted February 7, 2008 Vai manīgajam gadījuumā nebija @ zīme priekšā? Link to comment Share on other sites More sharing options...
7924 Posted February 8, 2008 Report Share Posted February 8, 2008 (edited) Vai manīgajam gadījuumā nebija @ zīme priekšā? Skiet ka @ bija jaliek prieksa globalajiem mainigajiem DELIMITER $$ DROP PROCEDURE IF EXISTS `test`.`tabulas_update`$$ CREATE DEFINER=`root`@`localhost` PROCEDURE `tabulas_update`(IN pieliekama_value TINYTEXT, IN saturosa_value TINYTEXT) BEGIN SET @aaa=saturosa_value; UPDATE tb_options SET option_name = concat(pieliekama_value, option_name) WHERE option_name LIKE %@aaa%; END$$ DELIMITER; tāpatās neņem pretī :( andrisp, Tu esi superhero, strādā šis: DELIMITER $$ DROP PROCEDURE IF EXISTS `test`.`tabulas_update`$$ CREATE DEFINER=`root`@`localhost` PROCEDURE `tabulas_update`(IN pieliekama_value TINYTEXT, IN saturosa_value TINYTEXT) BEGIN SET @aaa=saturosa_value; UPDATE tb_options SET option_name = concat(pieliekama_value, option_name) WHERE option_name LIKE concat('%', @aaa, '%', ''); END$$ DELIMITER; strādā gan ar atsevišķi globālo mainīgo @aaa, gan arī ar iekšējo mainīgo: saturosa_value bez "@" :) Edited February 8, 2008 by 7924 Link to comment Share on other sites More sharing options...
Recommended Posts