SELECT * FROM tCity WHERE CountryCode =
(SELECT Code FROM tCountry WHERE CountryName LIKE 'Estonia')
INSERT INTO tCity
VALUES((SELECT MAX(ID)+1 FROM tCity),'Narva',
(SELECT Code FROM tCountry WHERE CountryName LIKE 'Estonia'),
NULL,
0
)
INSERT INTO tCity(ID, CityName, CountryCode, Population)
VALUES((SELECT MAX(ID)+1 FROM tCity),'Pärnu',
(SELECT Code FROM tCountry WHERE CountryName LIKE 'Estonia'),
0
)
UPDATE tCity
SET District = (SELECT DISTINCT District FROm tCity WHERE CityName LIKE 'Narva'),
Population=0
WHERE CityNAme LIKE 'K-J'
SELECT * , getdate() AS AddDate --uue tabeli loomiseks ja kirjete lisamiseks
INTO EestiLinnad
FROM tCity
WHERE CountryCode LIKE 'EST'
INSERT INTO Eestilinnad
SELECT *,getdate()
FROM tCity
WHERE CountryCode LIKE
(SELECt Code FROM tCountry WHERE CountryName LIKE 'Latvia')
SELECT * FROM Eestilinnad
WHERE CityName LIKE '%J_rve'
UPDATE Eestilinnad
SET Population=45454
WHERE CityName LIKE '%J_rve'
--DELETE FROM EestiLinnad
SELECT * FROM EestiLinnad
--1. Kopeerige tabelisse EestiLinnad regiooni Baltic Countries kirjed
--2. Eemaldage tabelitest Estonia minimaalse elanikude arvuga linna andmed
INSERT INTO EestiLinnad
SELECT *, getdate()
FROM tCity
WHERE CountryCode IN
(SELECT Code FROM tCountry WHERE Region LIKE 'Baltic Countries')