BD Libreria | Consultas MYSQL

430 views

Published on

Published in: Technology
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total views
430
On SlideShare
0
From Embeds
0
Number of Embeds
14
Actions
Shares
0
Downloads
5
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

BD Libreria | Consultas MYSQL

  1. 1. BASE DE DATOS MYSQL ISC. JOSÉ FRANCISCO ORTIZ MARTINEZ
  2. 2. CREAR BASE DE DATOS CREATE DATABASE LIBRERIA; CREATE DATABASE NOMBRE;
  3. 3. CREAR TABLA (DICCIONARIO DE DATOS) CREATETABLE LIBROS(ID_LIBRO INT UNSIGNED NOT NULLAUTO_INCREMENT ,NOMBRE VARCHAR(40) , AUTORVARCHAR(30), PAGINAS INT,PAISVARCHAR (30), PRIMARY KEY(ID_LIBRO)); CREATETABLE NOMBRE (COLUMNAS);
  4. 4. INGRESAR DATOS. INSERT INTO LIBROS(NOMBRE, AUTOR, PAGINAS,PAIS)VALUES ("Laberinto de la soledad ", " Octavio Paz", "1500", "México"), ("Ecce homo", "Friedrich Nietzsche", "2500", "Alemania") , ("Lobo estepario", "Hermann Hesse", "1000", "Alemania"), ("Puertas al campo", "Octavio Paz", "900", "México"), ("Lobo estepario", "Hermann Hesse", "8000", "Alemania"); INSERT INTO NOMBRE (COLUMNAS)VALUES(DATOS);
  5. 5. CONSULTAS MYSQL.
  6. 6. SELECT CAMPOS FROMTABLA; SELECT * FROM LIBROS;
  7. 7. SELECT * FROMTABLA ORDER BY CAMPO; ORDENAR DATOS A-Z SELECT * FROM LIBROS ORDER BY NOMBRE;
  8. 8. SELECT * FROMTABLA ORDER BY CAMPO DESC; ORDENAR DATOS Z-A SELECT * FROM LIBROS ORDER BY NOMBRE DESC;
  9. 9. SELECT CAMPOS FROMTABLA WHERE CAMPO="1"; SELECT * FROM LIBROS WHERE ID_LIBRO="1";
  10. 10. SELECT CAMPOS FROMTABLA WHERE CAMPO>100; SELECT NOMBRE,PAGINAS FROM LIBROS WHERE PAGINAS>5000;
  11. 11. MODIFICAR DATOS.
  12. 12. UPDATETABLA SET CAMPO="DATO" WHERE ID_LIBRO="1"; UPDATE LIBROS SET PAGINAS="200" WHERE ID_LIBRO="1";
  13. 13. ELIMINAR DATOS.
  14. 14. DELETE FROMTABLAWHERE ID="1"; DELETE FROM LIBROSWHERE ID_LIBRO="1";
  15. 15. Cuando la información se organiza, surgen las ideas. Jim Rohn

×