Question: I am trying to work out how the SQL if I want to bring back ALL "Names" from table1 and only list the output in Column 2 to contain the value if it is "Apple". If its not "Apple" or is "Null" then column 2 should also be "Null"

Table 1

| **ID(pk)** | **Name** |
| --- | --- |
| 24 | Boris |
| 25 | Dominic |
| 26 | Rishi |
| 27 | Elizabeth |
| 28 | Ben |

Table 2

| **ID(fk)** | **Description** |
| --- | --- |
| 27 | Apple |
| 27 | Orange |
| 27 | Pear |
| 26 | Apple |
| 26 | Pear |
| 25 | Pear |
| 24 | Orange |

Required Output

| **Name** | **Description** |
| --- | --- |
| Boris |  |
| Dominic |  |
| Rishi | Apple |
| Elizabeth | Apple |
| Sajid |  |

Answer: 
You can do it this way:

```
  #include <type_traits>

  template <class A, class B> class Foo {};

  class Bar : public Foo<int, float> {};

  template <class A, class B> 
  std::true_type checkFoo(const Foo<A,B>&);

  std::false_type checkFoo(...);

  int main()
  {   
      Bar bar;
      int baz;
      static_assert(decltype(checkFoo(bar))::value, "bar test failed");;
      static_assert(!decltype(checkFoo(baz))::value, "baz test failed");;
  }                                                         

```
My version with C++14 (can be tweaked to C++11 easily):

```cpp
template <template<typename...> typename T, class... U>
void callWithTemplateBase(const T<U...>&);

template <typename T, template<typename...> typename Base, typename U = void>
struct IsInstanceOfTemplate : std::false_type {};

template <typename T, template<typename...> typename Base>
struct IsInstanceOfTemplate<
        T, 
        Base, 
        decltype(callWithTemplateBase<Base>(std::declval<T>()))> 
    : std::true_type {};

template <typename T, template<typename...> typename Base>
constexpr bool IsInstanceOfTemplate_v = IsInstanceOfTemplate<T, Base>::value;

template <class... T>
struct Foo {};

template<typename T>
constexpr bool IsFoo_v = IsInstanceOfTemplate_v<T, Foo>;

```

<https://godbolt.org/z/sv7jTPbE6>