
03/04/2012, 00:57
|
Colaborador | | Fecha de Ingreso: marzo-2008 Ubicación: Sabadell
Mensajes: 4.897
Antigüedad: 17 años Puntos: 574 | |
Respuesta: vista desobediente!!
Código MySQL:
Ver originalselect week(`tbl_1351_fisiologia`. `fechahora`,0) AS `Semana`, cast (`tbl_1351_fisiologia`. `fechahora` as date) AS `Fecha`, `tbl_1550_ciclo`. `wop` AS `Semana_planta`, `tbl_1550_ciclo`. `woc` AS `Semana_ciclo`, concat_ws(` `,`tbl_1550_ciclo`. `wop`,`tbl_1550_ciclo`. `ciclo`) AS `orden`, `tbl_1550_ciclo`. `ciclo` AS `Ciclo`,`tbl_1070_predios`. `nombre` AS `Nombre_predio`, `tbl_1350_fisiologia_puntos`. `alia s` AS `Muestra`, `tbl_1110_cuestionarios`. `pregunta` AS `Pregunta`, `tbl_1352_cuestionario_fisiologia`. `res puesta` AS `Planta_1`, `tbl_1352_cuestionario_fisiologia`. `res puesta2` AS `Planta_2`, `tbl_1352_cuestionario_fisiologia`. `res puesta3` AS `Planta_3`, `tbl_1352_cuestionario_fisiologia`. `res puesta4` AS `Planta_4`, `tbl_1352_cuestionario_fisiologia`. `res puesta5` AS `Planta_5`, (((((`tbl_1352_cuestionario_fisiologia` .`respuesta` + `tbl_1352_cuestionario_fisiologia`.`respuesta2`) + `tbl_1352_cuestionario_fisiologia`.`respuesta3`) + `tbl_1352_cuestionario_fisiologia`.`respuesta4`) + `tbl_1352_cuestionario_fisiologia`. `respuesta5`) / 5) AS `Promedio`, `tbl_1351_fisiologia`. `punto_id` AS `Punto_id`, `tbl_1351_fisiologia`. `id` AS `Muestra_id` from (((((`tbl_1351_fisiologia` join `tbl_1070_predios`) join `tbl_1352_cuestionario_fisiologia`) join `tbl_1350_fisiologia_puntos`) join `tbl_1110_cuestionarios`) where ((`tbl_1352_cuestionario_fisiologia`. `fisiologia_i d` = `tbl_1351_fisiologia`. `id`) and (`tbl_1350_fisiologia_puntos`. `id` = `tbl_1351_fisiologia`. `punto_id`) and (`tbl_1350_fisiologia_puntos`. `predio_id` = `tbl_1070_predios`. `id`) and (`tbl_1110_cuestionarios`. `id` = `tbl_1352_cuestionario_fisiologia`. `cuestionario_i d`) and (`tbl_1550_ciclo`. `predio_id` = `tbl_1070_predios`. `id`) and (`tbl_1550_ciclo`. `woy` = week(`tbl_1351_fisiologia`. `fechahora`,0)));
Manual - CONCAT(str1,str2,...)
Returns the string that results from concatenating the arguments. May have one or more arguments. If all arguments are nonbinary strings, the result is a nonbinary string. If the arguments include any binary strings, the result is a binary string. A numeric argument is converted to its equivalent binary string form; if you want to avoid that, you can use an explicit type cast, as in this example:
SELECT CONCAT(CAST(int_col AS CHAR), char_col); CONCAT() returns NULL if any argument is NULL. - mysql> SELECT CONCAT('My', 'S', 'QL'); -> 'MySQL'
- mysql> SELECT CONCAT('My', NULL, 'QL'); -> NULL
- mysql> SELECT CONCAT(14.3); -> '14.3'
- For quoted strings, concatenation can be performed by placing the strings next to each other:
- mysql> SELECT 'My' 'S' 'QL'; -> 'MySQL'
- CONCAT_WS(separator,str1,str2,...)
CONCAT_WS() stands for Concatenate With Separator and is a special form of CONCAT(). The first argument is the separator for the rest of the arguments. The separator is added between the strings to be concatenated. The separator can be a string, as can the rest of the arguments. If the separator is NULL, the result is NULL. - mysql> SELECT CONCAT_WS(',','First name','Second name','Last Name'); -> 'First name,Second name,Last Name'
- mysql> SELECT CONCAT_WS(',','First name',NULL,'Last Name'); -> 'First name,Last Name'
- CONCAT_WS() does not skip empty strings. However, it does skip any NULL values after the separator argument.
Una sugerencia JOIN Syntax
__________________ Quim
--------------------------------------------------
Ayudar a ayudar es una buena práctica!!! Y da buenos resultados. |