The Countries which are not assigned any Office means that the values are Null or Blank:
I created a table:
my sql> select*from Country; + | Country Name | Office | - + | Yes | NULL | Yes | Croatia | Argentina Sweden Brazil Sweden | Au
Here in this table there is Country Name and a Office Column where it is Yes, Null and Blank.
So, we need to delete the Blank and Null values as these means that there are no office assigned to those countries.
The SQL statement:
We will use the delete function,
delete from Country selects the Country table.
where Office is Null or Office = ' ' ,checks for values in Office column which are Null or Blank and deletes it.
Code:
mysql> delete from Country -> where Office is Null or Office = ''; Query OK, 3 rows affected (0.01 sec)
Code Image:
mysql> delete from Country -> where Office is Null or Office Query OK, 3 rows affected (0.01 sec) =
Output:
mysql> select*from Country; + | Country Name | Office | + | Croatia Sweden Sweden | India | Yes | Yes Yes | Yes + 4 rows in s
You can see that all the countries with Null and Blank values are deleted