1. Complete below SQL statement to find count of records from Customers table.
SELECT Country, State, City, Count(*) AS Count
FROM Customers
2. Add FK on child_table (column1) refrencing from parent_table
(column1).
ALTER TABLE child_table
As the 1st answer is already been provided I will attempt the 2nd answer.
2Ans)
We can use the key constraint FOREIGN KEY and REFERENCES to create a reference from the child_table(column1) to the parent_table(column1).
It is to be noted that the column we are referencing in parent_table should be primary key, It is because all the values in that column should be unique. Else creating a foreign key will create errors.
So the required SQL query is:
ALTER TABLE child_table
ADD FOREIGN KEY(column1) REFERENCES parent_table(column1)
Hope it helps!!!
Get Answers For Free
Most questions answered within 1 hours.