PHP mySQL - select unique value that not being used from dirrefent table
- by apis17
Updates : Please see below
i have table: data
+-----------------------+--------------+-----------+
| State | d_country | d_postcode|
+-----------------------+--------------+-----------+
| State1 | Country1 | 1111 |
| State2 | Country2 | 2222 |
| State3 | Country3 | 3333 |
| State4 | Country4 | 4444 |
+-----------------------+--------------+-----------+
And another table: user
+-----------------------+--------------+-----------+
| Name | u_country | u_postcode|
+-----------------------+--------------+-----------+
| Name1 | Country3 | 3333 |
| Name2 | Country5 | 5555 |
| Name3 | | 6666 |
| Name4 | Country6 | 6666 |
| Name5 | Country6 | 6666 |
+-----------------------+--------------+-----------+
What SQL should i use to:
Determine the number (count) of country that are not listed on table data. For example u_postcode is not listed in d_postcode is 5555 and 6666. It will return 2.
List down name and what country not available in table data yet.
Updates
I want to use grouping to filter postcode and make Name3 and Name4 as different rows.
For example:
+-----------------------+--------------+-----------+
| Name | u_country | u_postcode|
+-----------------------+--------------+-----------+
| Name2 | Country5 | 5555 |
| Name3 | | 6666 |
| Name4 | Country6 | 6666 |
+-----------------------+--------------+-----------+
Any possible idea?