Foros del Web » Programación para mayores de 30 ;) » Bases de Datos General » Mysql »

vista desobediente!!

Estas en el tema de vista desobediente!! en el foro de Mysql en Foros del Web. buenas tardes tengo esta cuerie select 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(`tbl_1550_ciclo`.`wop`,_utf8' ',`tbl_1550_ciclo`.`ciclo`) AS `orden`, `tbl_1550_ciclo`.`ciclo` AS ...
  #1 (permalink)  
Antiguo 02/04/2012, 14:48
Avatar de dorde  
Fecha de Ingreso: diciembre-2003
Mensajes: 145
Antigüedad: 20 años, 4 meses
Puntos: 7
Pregunta vista desobediente!!

buenas tardes


tengo esta cuerie

select 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(`tbl_1550_ciclo`.`wop`,_utf8' ',`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`) join `tbl_1550_ciclo`) 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)))


PROBLEMA: ESTA ES UNA VISTA QUE CONSULTO VIA ODBC DESDE EXCEL, YO DO BINE EXEPTO LA COLUMNA QUE DICE ORDEN, ESA NO APARECE!!! EN UN PROGRAMA QUE HACE COSAS SIMILARES AL EXCEL ME MARCA QUE ES UN DATO BINARIO... ¿¿¿¿QUE PODRE HACER????
__________________
Pero si alguno de vosotros se ve falto de sabiduría, que la pida a Dios, el cual da a todos abundantemente y sin reproche, y le será dada. Pero que pida con fe, sin dudar

Santiago 1.5-6
  #2 (permalink)  
Antiguo 03/04/2012, 00:57
Colaborador
 
Fecha de Ingreso: marzo-2008
Ubicación: Sabadell
Mensajes: 4.897
Antigüedad: 16 años, 1 mes
Puntos: 574
Respuesta: vista desobediente!!

Código MySQL:
Ver original
  1. select week(`tbl_1351_fisiologia`.`fechahora`,0) AS `Semana`,
  2.           cast(`tbl_1351_fisiologia`.`fechahora` as date) AS `Fecha`,
  3.           `tbl_1550_ciclo`.`wop` AS `Semana_planta`,
  4.           `tbl_1550_ciclo`.`woc` AS `Semana_ciclo`,
  5.             concat_ws(` `,`tbl_1550_ciclo`.`wop`,`tbl_1550_ciclo`.`ciclo`) AS `orden`,
  6.           `tbl_1550_ciclo`.`ciclo` AS `Ciclo`,`tbl_1070_predios`.`nombre` AS `Nombre_predio`,
  7.            `tbl_1350_fisiologia_puntos`.`alia s` AS `Muestra`,
  8.            `tbl_1110_cuestionarios`.`pregunta` AS `Pregunta`,
  9.            `tbl_1352_cuestionario_fisiologia`.`res puesta` AS `Planta_1`,
  10.            `tbl_1352_cuestionario_fisiologia`.`res puesta2` AS `Planta_2`,
  11.            `tbl_1352_cuestionario_fisiologia`.`res puesta3` AS `Planta_3`,
  12.            `tbl_1352_cuestionario_fisiologia`.`res puesta4` AS `Planta_4`,
  13.            `tbl_1352_cuestionario_fisiologia`.`res puesta5` AS `Planta_5`,
  14.            (((((`tbl_1352_cuestionario_fisiologia` .`respuesta` +
  15.                  `tbl_1352_cuestionario_fisiologia`.`respuesta2`) +
  16.                  `tbl_1352_cuestionario_fisiologia`.`respuesta3`) +
  17.                  `tbl_1352_cuestionario_fisiologia`.`respuesta4`) +
  18.                  `tbl_1352_cuestionario_fisiologia`.`respuesta5`) / 5) AS `Promedio`,
  19.                  `tbl_1351_fisiologia`.`punto_id` AS `Punto_id`,
  20.                  `tbl_1351_fisiologia`.`id` AS `Muestra_id`
  21. from (((((`tbl_1351_fisiologia` join `tbl_1070_predios`)
  22.                   join `tbl_1352_cuestionario_fisiologia`)
  23.                   join `tbl_1350_fisiologia_puntos`)
  24.                   join `tbl_1110_cuestionarios`)
  25.                   join `tbl_1550_ciclo`)
  26. where ((`tbl_1352_cuestionario_fisiologia`.`fisiologia_i d` = `tbl_1351_fisiologia`.`id`)
  27.              and (`tbl_1350_fisiologia_puntos`.`id` = `tbl_1351_fisiologia`.`punto_id`)
  28.               and (`tbl_1350_fisiologia_puntos`.`predio_id` = `tbl_1070_predios`.`id`)
  29.               and (`tbl_1110_cuestionarios`.`id` = `tbl_1352_cuestionario_fisiologia`.`cuestionario_i d`)
  30.               and (`tbl_1550_ciclo`.`predio_id` = `tbl_1070_predios`.`id`)
  31.               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.
  #3 (permalink)  
Antiguo 03/04/2012, 08:20
Avatar de dorde  
Fecha de Ingreso: diciembre-2003
Mensajes: 145
Antigüedad: 20 años, 4 meses
Puntos: 7
Respuesta: vista desobediente!!

Gracias, pero sigo con el mismo problema, no se ve en excel...
__________________
Pero si alguno de vosotros se ve falto de sabiduría, que la pida a Dios, el cual da a todos abundantemente y sin reproche, y le será dada. Pero que pida con fe, sin dudar

Santiago 1.5-6
  #4 (permalink)  
Antiguo 03/04/2012, 09:24
Colaborador
 
Fecha de Ingreso: enero-2007
Ubicación: México
Mensajes: 2.097
Antigüedad: 17 años, 3 meses
Puntos: 447
Respuesta: vista desobediente!!

Hola dorde:

Probaste la primer recomendación que aparece en la documentación???

Cita:
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.
Tus campos wop y ciclo de casualidad son numéricos??? si es así entonces DEBES HACER LA CONVERSIÓN EXPLÍCITA

Código:
concat(CAST(`tbl_1550_ciclo`.`wop` AS CHAR), ' ',
 CAST(`tbl_1550_ciclo`.`ciclo` AS CHAR)) AS `orden
Saludos
Leo.
  #5 (permalink)  
Antiguo 11/04/2012, 11:29
Avatar de dorde  
Fecha de Ingreso: diciembre-2003
Mensajes: 145
Antigüedad: 20 años, 4 meses
Puntos: 7
Respuesta: vista desobediente!!

esos campos jalan bien , el que no funciona es
concat(`tbl_1550_ciclo`.`wop`,_utf8' ',`tbl_1550_ciclo`.`ciclo`) AS `orden`,

aca me pone un valor varbinary!!
__________________
Pero si alguno de vosotros se ve falto de sabiduría, que la pida a Dios, el cual da a todos abundantemente y sin reproche, y le será dada. Pero que pida con fe, sin dudar

Santiago 1.5-6

Etiquetas: join, select, vistas
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 07:16.