Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
BRYANActual
CREATE TABLE Control_ventas( Nombre varchar(25) NOT NULL, Producto varchar (25)NOT NULL, ID_Producto int UNIQUE NOT NULL, Precio money, Fecha varchar(20) NOT NULL, ); CREATE TABLE Control_pedidos( num_de_pedido int, Tipo_de_pedido Varchar(25) NULL, Sobre_caja Varchar(15) NULL, FRAGIL Varchar(15) NULL, UNIDADES int, Direccion Varchar(25) NULL, Codigo_postal int, ID_Producto int UNIQUE NOT NULL, ); INSERT INTO Control_ventas (Nombre,Producto,ID_Producto,Precio, Fecha) VALUES ('Paula','Iphone 7', '15468','5','21/octubre/2020'), ('Bryan','Perfume', '54684', '8', '27/octubre/2020'), ('Carlos','Bocina', '22782', '4', '24/octubre/2020'), ('Luis','Jueguete', '789024', '9', '26/octubre/2020'), ('David','Mueble', '26554', '22', '29/octubre/2020'), ('Diego','Agua', '45785', '24', '22/octubre/2020') SELECT * FROM [Control_ventas]; INSERT INTO Control_pedidos (num_de_pedido,Tipo_de_pedido,Sobre_caja,FRAGIL,UNIDADES, DIRECCION, CODIGO_POSTAL, ID_Producto) VALUES ('2795','Iphone 7','CAJA','NO','4','QUERETARO 265','01879','15468'), ('4587','Perfume','CAJA','SI','8','GONZALEZ 68','02457','54684'), ('3657','Bocina','CAJA','SI','3','Mimosa 28','01770','22782'), ('8965','Juguete','CAJA','NO','7','Durango 458','05489','789024'), ('2654','Mueble','CAJA','NO','10','Rinconada 34','01987','26554'), ('5631','Agua','CAJA','NO','24','Noviembre 34','03654','45785') SELECT * FROM [Control_pedidos]; SELECT Producto FROM Control_ventas LEFT JOIN Control_pedidos ON Control_ventas.Producto=Control_pedidos.Tipo_de_pedido; SELECT Tipo_de_pedido FROM Control_pedidos RIGHT JOIN Control_ventas ON Control_pedidos.Tipo_de_pedido=Control_ventas.Producto; --SELECT Producto --FROM Control_ventas --OUTER JOIN Control_pedidos --ON Control_ventas.Producto=Control_pedidos.Tipo_de_pedido; --UPDATE UPDATE Control_ventas SET ID_Producto= '11111' WHERE Nombre= 'Pedro' AND Producto = 'Iphone 8'; select *from [Control_ventas]; --DELETE DELETE Control_ventas where Producto = 'Iphone 7'; select * from[Control_ventas]; --DROP DROP TABLE Control_Pedidos; --ALTER ALTER TABLE Control_ventas ADD num_telefono Varchar(25); SELECT * FROM [Control_ventas];
run
|
edit
|
history
|
help
0
Use the right tool to get identity values back after an insert
using lead() and sum() with over() in mssql
Teacher
QLSV
SQL injection
Update Temp table to Insert node in XML data using SQL
products table
MERGE WITH OUTPUT
Co-Related sub query
TRY_SQL