chatGPT-MySQL_Interview_Questions
chatGPT-MySQL_Interview_Questions
1. What is MySQL?
(Structured Query Language). It is used to manage and organize data in a relational database and
Answer:
```sql
```
Write a query to create a table named `employees` with columns `id`, `name`, and `salary`.
Answer:
```sql
name VARCHAR(100),
salary DECIMAL(10, 2)
);
```
Common MySQL Interview Questions and Answers
Answer:
```sql
```
Answer:
```sql
```
Write a query to update the salary of the employee with `id` 1 to 55000.
Answer:
```sql
```
Write a query to delete the employee with `id` 1 from the `employees` table.
Answer:
```sql
```
A JOIN clause is used to combine rows from two or more tables, based on a related column
between them.
Write a query to perform an INNER JOIN between the `employees` table and a `departments` table
Answer:
```sql
FROM employees
```
A PRIMARY KEY is a unique identifier for a table. It ensures that each record in a table is unique
Write a query to add a PRIMARY KEY to the `id` column of the `employees` table.
Answer:
```sql
```
A FOREIGN KEY is a field (or collection of fields) in one table that refers to the PRIMARY KEY in
another table. It helps maintain referential integrity between the two tables.
Write a query to add a FOREIGN KEY to the `department_id` column in the `employees` table that
Answer:
```sql
```
Answer:
```sql
```
Answer:
```sql
```