Sentencias MySQL
(INSERT, UPDATE, SELECT)
SENTENCIA SELECT
·
Sintaxis (con una tabla)
SELECT [campo1], [campo2],
[...], [campoN]
FROM <Nombre Tabla>
Ejemplo:
SELECT M_PELI.PELI_chNOMPEL
FROM M_PELI
·
Sintaxis (concatenando, con Clausula ORDER BY)
SELECT CONCAT ([campo1], [campo2],
[...], [campoN]) AS <Nombre de
Columna>
FROM <Nombre
Tabla>
ORDER BY [campo1] [ASC] [DESC], [campo2] [ASC]
[DESC], [...], [campoN] [ASC] [DESC]
Ejemplo:
SELECT CONCAT(M_CLIE.CLIE_chAPEPAT,
“ “, M_CLIE.CLIE_chAPEMAT, “ “, M_CLIE.CLIE_chNOMCLI) AS CLIE_chNOMCLI
FROM M_CLIE
ORDER BY M_CLIE.CLIE_chAPEPAT, M_CLIE.CLIE_chAPEMAT,
M_CLIE.CLIE_chNOMCLI
·
Sintaxis (concatenando, con Condicional WHERE)
SELECT CONCAT ([campo1], [campo2],
[...], [campoN]) AS <Nombre de
Columna>
FROM <Nombre
Tabla>
WHERE [Condicion1] = [ValorCondicion1]
Ejemplo:
SELECT CONCAT(M_CLIE.CLIE_chAPEPAT,
“ “, M_CLIE.CLIE_chAPEMAT, “ “, M_CLIE.CLIE_chNOMCLI) AS CLIE_chNOMCLI
FROM M_CLIE
WHERE M_CLIE.CLIE_chCODCLI = “435889929”
SENTENCIA INSERT
·
Sintaxis
INSERT INTO <Nombre
Tabla>
VALUES ([campo1], [campo2], [...], [campoN])
Ejemplo:
INSERT INTO M_PELI
VALUE (11,”LOS VENGADORES”,1)
SENTENCIA UPDATE
·
Sintaxis
UPDATE <Nombre de la
Tabla>
SET [campo1]
= [Valor1],
[campo2] = [Valor2],
[…] = […],
[campoN] = [ValorN]
WHERE [Condicion1] =
[ValorCondicion1],
[Condicion2] =
[ValorCondicion2],
[…] = […],
[CondicionN] =
[ValorCondicionN],
Ejemplo:
UPDATE M_CLIE
SET CLIE_chCODCLI =
“87654321”
CLIE_chNOMCLI =
“CLIENTE VIP”
WHERE CLIE_P_inCODCLI = 2
No hay comentarios.:
Publicar un comentario