Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Gbd10

764 views

Published on

Published in: Business, Economy & Finance
  • Be the first to comment

Gbd10

  1. 1. Generandoscript de consultas y subconsultas<br /> <br />Base de datos (MySQL)<br />Ing. Linda Masias Morales<br />
  2. 2. Alias para nombres de Columnas<br />SELECT nombre as monitor <br />FROM taarticulo<br />SELECT nombre as monitor, imagen <br />FROM taarticulo<br />SELECT nombre as monitor, imagen as picture<br />FROM taarticulo<br />
  3. 3. Alias para nombres de Columnas<br />SELECT nombre as monitor, imagen as 'picture new' FROM taarticulo<br />SELECT nombre as monitor, CONCAT(precio,’,’,stock) as resumen<br />FROM taarticulo<br />
  4. 4. BETWEEN <br />SELECT nombre as monitor, CONCAT(precio,’,’,stock) as resumen<br />FROM taarticulo<br />WHERE precio BETWEEN 200 and 300<br />
  5. 5. IN<br />SELECT nombre as monitor, CONCAT(precio,',',stock) as resumen<br />FROM taarticulo<br />WHERE codproveedor IN (0617002, 0617004)<br />
  6. 6. NOT<br />SELECT nombre as monitor, CONCAT(precio,',',stock) as resumen<br />FROM taarticulo<br />WHERE (precio<200)<br />SELECT nombre as monitor, CONCAT(precio,',',stock) as resumen<br />FROM taarticulo<br />WHERE NOT (precio<200)<br />
  7. 7. Consultas de tiempo<br />Tablaproducto<br />SELECT category FROM producto WHERE (year(fecha)=2012)<br />SELECT category FROM productoWHERE (day(fecha)=11)<br />SELECT category FROM productoWHERE (month(fecha)=12)<br />SELECT category FROM productoWHERE (hour(hora)=03)<br />SELECT category FROM productoWHERE (minute(hora)=3)<br />SELECT category FROM productoWHERE (second(hora)=32)<br />
  8. 8. ORDER BY <br />SELECT * FROM taarticulo ORDER BY precio<br />SELECT * FROM taarticulo ORDER BY precio ASC<br />SELECT * FROM taarticulo ORDER BY precio DESC<br />SELECT * FROM tacategoria ORDER BY nombre<br />SELECT * FROM tacategoria ORDER BY nombre ASC<br />SELECT * FROM tacategoria ORDER BY nombre DESC<br />
  9. 9. ORDER BY <br />SELECT * FROM taarticulo<br />WHERE precio >= 250 <br />ORDER BY precio<br />
  10. 10. ORDER BY <br />SELECT * FROM taarticulo<br />WHERE precio >= 150 <br />ORDER BY 3<br />

×