Pessoal,

No treinamento nessa última sexta-feira, fizemos uma dinâmica para discutir, testar e avaliar funções.

Abaixo vou colocar o script gerado conforme fizemos, executamos tudo pelo Workbench 5.2.38 CE.

[et_pb_dmb_code_snippet _builder_version=”4.0.6″ code=”Y3JlYXRlIHRhYmxlIHN0cl90ZXN0ZShzdHJpbmcxIHZhcmNoYXIoMTAwKSk7CgojRVNDQVBFCmluc2VydCBpbnRvIHN0cl90ZXN0ZSB2YWx1ZXMgKCdGZXJuYW5kbycpOwp1cGRhdGUgc3RyX3Rlc3RlCnNldCBzdHJpbmcxID0gJ0Zlcm5hbmRvIGJhcnJpZ2EgZCcnYWd1YSc7CgpzZWxlY3QgKiBmcm9tIHN0cl90ZXN0ZTsKCiNkdWFzIGZvcm1hcyBkZSB1c2FyIG8gRVNDQVBFOwp1cGRhdGUgc3RyX3Rlc3RlCnNldCBzdHJpbmcxID0gJ0Zlcm5hbmRvIGJhcnJpZ2EgZCdhZ3VhIGQnJ3NpbGEnOwoKI2VuZCBFU0NBUEUKCiNMSUtFIFVQUEVSIExPV0VSCnNlbGVjdCAqCmZyb20gc3RyX3Rlc3RlCndoZXJlIHN0cmluZzEgTElLRSAnJWZlcm5hbmRvJSc7CgpzZWxlY3QgKiwgdXBwZXIoc3RyaW5nMSkKZnJvbSBzdHJfdGVzdGUKd2hlcmUgdXBwZXIoc3RyaW5nMSkgTElLRSB1cHBlcignJWZlcm5hbmRvJScpOwoKc2VsZWN0ICogLCBsb3dlcihzdHJpbmcxKSwgdXBwZXIoc3RyaW5nMSkKZnJvbSBzdHJfdGVzdGUKd2hlcmUgbG93ZXIoc3RyaW5nMSkgTElLRSBsb3dlcignJWZlcm5hbmRvJScpOwoKI0NPTkNBVCAtIENPTlRFVE5BIHN0cjEsIHN0cjIgLi4uIHN0cm4KI1VQUEVSIG1haXVzY3VsYXMKI0xPV0VSIG1pbnVzY3VsYXMKI0xFTkdUSCB0YW1hbmhvCiNVQ0FTRSAtIHVwcGVyCiNMQ0FTRSA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lOwoKI0RBVEFTCnNlbGVjdCBub3coKSwgY3VycmVudF9kYXRlLCBjdXJkYXRlKCksCmN1cnJlbnRfdGltZSwgY3VycmVudF90aW1lc3RhbXAKCiNmb3JtYXRhY2FvIGRhdGEKc2VsZWN0IG5vdygpLCBkYXRlX2Zvcm1hdChub3coKSwnJUgnKSBhcyBIT1JBLApkYXRlX2Zvcm1hdChub3coKSwnJU0nKSBNRVMsCmRhdGVfZm9ybWF0KG5vdygpLCclYicpIG1lcywKZGF0ZV9mb3JtYXQobm93KCksJyVZJykgWVlZWSwKZGF0ZV9mb3JtYXQobm93KCksJyV5JykgeXksCmRheW5hbWUobm93KCkpOwoKI0NBU0UKc2VsZWN0CmNhc2UgZGF5bmFtZShub3coKSkKd2hlbiAnRnJpZGF5Jwp0aGVuICdTRVhUQSBIVUhVISEnCmVuZCBhcyBhOwoKc2VsZWN0IG1kNSgnY2FwaW4nKTsKc2VsZWN0IHNoYTEoJ2NhcGluJyk7CnNlbGVjdCBwYXNzd29yZCgnY2FwaW4nKTs=[/et_pb_dmb_code_snippet]

OBS.: BUG do Workbench: A consulta abaixo para funcionar precisa que seja selecionado e executado, caso não seja feito dessa forma, e seja utilizado somente a execução da linha (ou CTRL + ENTER) dará erro!

[et_pb_dmb_code_snippet _builder_version=”4.0.6″ code=”I2Zvcm1hdGFjYW8gZGF0YQpzZWxlY3Qgbm93KCksIGRhdGVfZm9ybWF0KG5vdygpLCclSCcpIGFzIEhPUkEsCmRhdGVfZm9ybWF0KG5vdygpLCclTScpIE1FUywKZGF0ZV9mb3JtYXQobm93KCksJyViJykgbWVzLApkYXRlX2Zvcm1hdChub3coKSwnJVknKSBZWVlZLApkYXRlX2Zvcm1hdChub3coKSwnJXknKSB5eSwKZGF5bmFtZShub3coKSk7″ hover_enabled=”0″]I2Zvcm1hdGFjYW8gZGF0YQpzZWxlY3Qgbm93KCksIGRhdGVfZm9ybWF0KG5vdygpLCclSCcpIGFzIEhPUkEsCmRhdGVfZm9ybWF0KG5vdygpLCclTScpIE1FUywKZGF0ZV9mb3JtYXQobm93KCksJyViJykgbWVzLApkYXRlX2Zvcm1hdChub3coKSwnJVknKSBZWVlZLApkYXRlX2Zvcm1hdChub3coKSwnJXknKSB5eSwKZGF5bmFtZShub3coKSk7[/et_pb_dmb_code_snippet]

Para mostrar mais informações sobre funções do MySQL podem acessar a documentação oficial.
Funções e Operadores;
Funções para String;
Funções Numéricas e Operadores;
Funções para Data e Hora;

Espero ter colaborado.
Att,
capin