Gb

569 views

Published on

Published in: Business, Economy & Finance
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total views
569
On SlideShare
0
From Embeds
0
Number of Embeds
4
Actions
Shares
0
Downloads
10
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

Gb

  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 (time(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 />

×