sql1

an anonymous user · September 23, 2022
CREATE TABLE city(
    cid INT NOT NULL,
    cityname VARCHAR(50) NOT NULL,
    PRIMARY KEY(cid)
);
INSERT INTO city(cid, cityname)
VALUES
(1,'Agra'),
(2,'Jaipur'),
(3,'Delhi'),
(4,'Ayodhya');
CREATE TABLE student(
   id INT,
   name VARCHAR(10),
   age INT,
   city INT,
   PRIMARY KEY(id),
   FOREIGN KEY(city) REFERENCES city(cid)
);
INSERT INTO student(id, name, age, city)
VALUES
(1, "sandy", 21, "Gkp"),
(2, "mandy", 22, "Lko"),
(3, "randy", 23, "Jpr"),
(4, "tandy", 24, "Kota");
SELECT * FROM student INNER JOIN city
ON student.city = city.cid;
Output
(Run the program to view its output)

Comments

Please sign up or log in to contribute to the discussion.