CONCAT (MySQL)
Naar navigatie springen
Naar zoeken springen
Voorbeeld
concat( Dim1NL, "x", Dim2NL, "x", Dim3NL, "mm" )
Syntaxis - In scripts
Bij sommige commando's moet het openingshaakje direct achter het keywoord staan. Dat is hier niet het geval - Dit werkt:
select concat ( 1, 2, 3 ) as blub;
Commentaarregels zijn ook geen probleem:
select concat ( # Nu komt het eerste argument ############################# # 1, # Nu komt het tweede argument ############################# # 2, # Nu komt het derde argument ############################ # 3 ) as blub;
Syntaxis - In sprocs
Syntaxis lijkt voor sprocs niet anders te zijn:
CREATE DEFINER=`root`@`localhost` PROCEDURE `concat_test`() BEGIN select concat (1,2,3) as blub_01; select concat ( 4, 5, 6 ) as blub_02; select concat ( # Eerste argument ################# # 7, # Tweede argument ################# # 8, # Derde argument ################ # 9 ) as blub_03; END
Incorrect column name 'concat'-foutmelding
De complete foutmelding, die me in maart 2018 parten speelde:
14:47:35 call superquery_prepare_description() Error Code: 1166. Incorrect column name 'concat ( "<b>Set von zwei xxxxxxxxxxx Yyyyüyyy</b>", 1, 2, 3 )' 0,0059 sec
Oorzaak: De resulterende kolom had geen eigen naam gekregen, en werd zodoende deze uitdrukking, en dat was blijkbaar te gortig voor MySQL.
Oplossing: Voeg as xxx
toe. Bv.:
select concat ( "<b>Set von zwei xxxxx Yyyyüyyy</b>", ifnull(concat(" für ", brands, " Handwerkzeuge"), " für Handwerkzeuge"), ifnull(concat(" - Abmessungen: ",dim1,"x",dim2,"x",dim3,"mm"),""), ifnull(concat(" - Ersatz für diese Original-abc: ",orgbrush_tmp5.orgbrush_id),""), if(automatic_stop=0, ""," - Mit automatischer Abschaltung") ) as basis # DEZE REGEL MAAKT HET VERSCHIL from root_tmp