Ver Mensaje Individual
  #2 (permalink)  
Antiguo 03/08/2012, 18:03
pollin14
 
Fecha de Ingreso: marzo-2010
Ubicación: df
Mensajes: 58
Antigüedad: 14 años, 2 meses
Puntos: 5
Respuesta: Como puedo realizar una consulta cruzada entre dos tablas?

Hola!

Yo lo haria así:

Código MySQL:
Ver original
  1. use test;
  2.  
  3. drop table if exists vista_general_personas;
  4.  
  5. create table vista_general_personas (id int);
  6.  
  7. insert into vista_general_personas values (1),(2),(3),(4),(5),(6),(7),(8),(9);
  8.  
  9.  
  10. DELIMITER $$
  11.  
  12. CREATE PROCEDURE totales()
  13.  
  14.  
  15.     DECLARE t INT;
  16.  
  17.     DECLARE valor INT DEFAULT 0;
  18.  
  19.     SELECT count(*) INTO t FROM vista_general_personas;
  20.  
  21.     SET valor = t - 2;  
  22.  
  23.     SELECT * FROM vista_general_personas LIMIT  valor;
  24.    
  25. END $$
  26. DELIMITER ;
  27.  
  28. call totales();

Saludos!

-------------------------------------------------------------------------------------
Workbench de MySql es un super programa que te hace la vidad mas bonita
__________________
Dead Nation