title: Query inner join 3 tables
body: <p>I´m traying to do this query:</p>
  <pre><code> SELECT DISTINCT a.codAsistencia
                 , a.fecha
                 , a.mensaje
                 , u.nombre
                 , u.id
                 , u.telefono
                 , c.tiempoRestanteBono
              FROM asistencia a
              JOIN users u
                ON a.usuario = u.id
              JOIN contratan c
                ON c.usuario = u.id
             WHERE a.codAsistencia = 2
  </code></pre>
  <p>I need get all this data when codAsistencia = x</p>
  <p>phpmyadmin returned a impty result, i don´t know very well to do queries with inner join... i attach one image for you can show realations</p>
  <p>i have to tell that i have a data en my tables, in contratan, users and asistencia... I don´t know that i´m doing wrong</p>
  <p>My data in asistencia is:</p>
  <pre><code>CREATE TABLE `asistencia` (
    `codAsistencia` int(10) UNSIGNED NOT NULL,
    `fecha` datetime NOT NULL,
    `mensaje` longtext COLLATE utf8mb4_unicode_ci NOT NULL,
    `usuario` bigint(20) UNSIGNED NOT NULL,
    `estado` varchar(20) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'pendiente',
    `created_at` timestamp NULL DEFAULT NULL,
    `updated_at` timestamp NULL DEFAULT NULL
  ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
  
  --
  -- Volcado de datos para la tabla `asistencia`
  --
  
  INSERT INTO `asistencia` (`codAsistencia`, `fecha`, `mensaje`, `usuario`, `estado`, `created_at`, `updated_at`) VALUES
  (2, '2020-11-11 11:27:09', 'prueba', 2, 'pendiente', NULL, NULL);
  </code></pre>
  <p>In contratan</p>
  <pre><code>CREATE TABLE `contratan` (
      `codContrato` int(10) UNSIGNED NOT NULL,
        `bono` int(10) UNSIGNED NOT NULL,
        `tiempoRestanteBono` int(10) UNSIGNED NOT NULL,
        `activo` tinyint(4) NOT NULL DEFAULT 0,
        `usuario` bigint(20) UNSIGNED NOT NULL
      ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
      
      --
      -- Volcado de datos para la tabla `contratan`
      --
      
      INSERT INTO `contratan` (`codContrato`, `bono`, `tiempoRestanteBono`, `activo`, `usuario`) VALUES
      (20, 1, 30, 1, 7);
  </code></pre>
  <p>In user</p>
  <pre><code>    CREATE TABLE `users` (
    `id` bigint(20) UNSIGNED NOT NULL,
    `nif` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
    `nombre` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
    `email` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
    `email_verified_at` timestamp NULL DEFAULT NULL,
    `password` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
    `direccion` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
    `perfil` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'usuario',
    `telefono` int(11) DEFAULT NULL,
    `remember_token` varchar(100) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
    `created_at` timestamp NULL DEFAULT NULL,
    `updated_at` timestamp NULL DEFAULT NULL
  ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
  
  --
  -- Volcado de datos para la tabla `users`
  --
  
  INSERT INTO `users` (`id`, `nif`, `nombre`, `email`, `email_verified_at`, `password`, `direccion`, `perfil`, `telefono`, `remember_token`, `created_at`, `updated_at`) VALUES
  (2, '123456', 'David Serrano Alonso', 'daviserraalonso@hotmail.com', NULL, '$2y$10$/BfMjo1J8W.UFtQAGTUX9O0Ae9RilA5JFipu0ZVnLWrwDSIQ65NBS', NULL, 'tecnico', NULL, NULL, '2020-11-08 10:59:29', '2020-11-08 10:59:29'),
  (3, '45921676z', 'David Serrano Alonso', 'daviserraalonso@pepemail.com', NULL, '$2y$10$wLEOohpZrxbAcFcKC07x5u5gNeA/zeJZwUWNLoec5FsrUfQ5P.9Nu', NULL, 'usuario', 652138927, NULL, '2020-11-11 07:56:12', '2020-11-11 07:56:12'),
  (7, '45921676z', 'David Serrano Alonso', 'daviserraalonso@gmail.com', '2020-11-11 08:21:19', '$2y$10$wT2YvsBlypLD.FjADnP0s.vk2liOq/tFM.vHeCGXO3jyGiBReyzsm', NULL, 'usuario', 652138927, NULL, '2020-11-11 08:20:46', '2020-11-11 08:21:19');
  </code></pre>
  <p><a href="https://i.stack.imgur.com/gl715.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/gl715.png" alt="enter image description here" /></a></p>
  <p>Thank you very much for help</p>