Advertisement
Guest User

Untitled

a guest
Nov 21st, 2019
126
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.35 KB | None | 0 0
  1. /*CREATE DATABASE Baza_A21*/
  2.  
  3. USE Baza_A21
  4.  
  5. /*CREATE TABLE Klient
  6. (
  7. idklienta int identity primary key not null,
  8. nazwa varchar(30),
  9. kod_pocztowy varchar(6) not null
  10. )
  11.  
  12. CREATE TABLE Towar
  13. (
  14. idtowaru int identity primary key not null,
  15. nazwa varchar(30) not null,
  16. jm varchar(5) not null,
  17. cena float not null
  18. )
  19.  
  20. CREATE TABLE Sprzedaz
  21. (
  22. id int identity primary key not null,
  23. klient int not null,
  24. towar int not null,
  25. ilosc int not null,
  26. data1 DATE not null
  27. )
  28. */
  29.  
  30. /*ALTER TABLE Sprzedaz ADD FOREIGN KEY (klient) REFERENCES Klient(idklienta)*/
  31. /*ALTER TABLE Sprzedaz ADD FOREIGN KEY (towar) REFERENCES Towar(idtowaru)*/
  32.  
  33. /*INSERT INTO Klient (nazwa, kod_pocztowy) VALUES ('Andrzej Nowak', '34-113'), ('Marysia', '09-395'), ('Pawlak', '63-604')
  34. INSERT INTO Towar (nazwa, jm, cena) VALUES ('Maslo', 'g', '5.99'), ('Twix', 'szt', '1.99'), ('Seta', 'ml', '4.99')
  35. INSERT INTO Sprzedaz (klient, towar, ilosc, data1) VALUES ('1', '3', '4', '2019-11-21'), ('2','1','1','2019-10-02'), ('3', '2', '2', '2018-12-22')*/
  36.  
  37. SELECT * FROM Towar WHERE cena>100
  38. SELECT * FROM Klient WHERE kod_pocztowy='63-600' ORDER BY nazwa DESC
  39. SELECT Klient.nazwa as NAZWA_KLIENTA, kod_pocztowy, Towar.nazwa as NAZWA_TOWARU, ilosc as ILOŚĆ, jm as JednMiary, cena as CENA, data1
  40. FROM Klient, Towar, Sprzedaz
  41. WHERE Sprzedaz.klient=Klient.idklienta
  42. AND Sprzedaz.towar=Towar.idtowaru
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement