Help with a query of two tables

1

I am making a login and in it, I want to consult two tables and that according to what I enter in the input, I bring a single result of the tables that I consult, I put the way I am doing it but I have not succeeded

SELECT u.id_usuario, u.id_tipousuario,rol, u.correo_usuario, u.contrasena_usuario, 
       tc.id_tienda,tc.id_tipousuario,tc.correo_tienda,tc.contrasena_tienda 
       FROM usuarios AS u, tiendas_cafe AS tc 
       INNER JOIN tipos_usuarios USING(id_tipousuario) 
       WHERE u.correo_usuario= :correo_usuario=tc.correo_tienda= :correo_tienda

Trying this other way:

SELECT * FROM usuarios,tiendas_cafe 
         WHERE correo_usuario=correo_tienda='correo' LIMIT 1

it brings me the result but it brings me the whole row of the other table

table structure

INSERT INTO      usuarios (          id_usuario ,          id_tipousuario ,          id_status ,          nombre_usuario ,          apellido_usuario ,          id_pais ,          id_ciudad ,          direccion_usuario ,          telefono_usuario ,          correo_usuario ,          genero ,          fecha_nacimiento_usuario ,          ubicacion_usuario ,          ltd_usuario ,          lng_usuario ,          contrasena_usuario ,          img_perfil_usuario     )

INSERT INTO      tiendas_cafe (          id_tienda ,          id_tipousuario ,          id_status ,          nombre_tienda ,          propietario ,          concepto ,          descripcion ,          id_pais ,          id_ciudad ,          direccion_tienda ,          telefono_tienda ,          correo_tienda ,          barista ,          tipo_cafe ,          fecha_aniversario ,          ubicacion_tienda ,          ltd_tienda ,          lng_tienda ,          contrasena_tienda ,          img_perfil_tienda ,          img_portada_tienda ,          img_galeria_tienda ,          url_video_tienda     )

The query would be something like this:

SELECT user_mail, mail_store FROM users or INNER JOIN stores_cafe tc ON u.id_typeuser = tc.id_typeuser WHERE u.user_mail = tc.mail_store LIKE'%[email protected]%'LIMIT 1

    
asked by jorgnv 18.08.2017 в 17:22
source

1 answer

1
SELECT u.id_usuario, u.id_tipousuario,rol, u.correo_usuario, u.contrasena_usuario, tc.id_tienda,tc.id_tipousuario, tc.correo_tienda, tc.contrasena_tienda

// In the from you must put a table (I leave user) that then you will relate the other table by JOIN:

FROM usuarios

// Now relate the other table

INNER JOIN tiendas_cafe

// After the inner join you must use an ON with two columns that relate the tables. I have put these but you will know which are specifically ...

ON u.id_tipousuario = tc.ts_tipousuario

// The following condition must be a "=", "like", concatenate, etc. or several conditions, etc., but doing a = = = is incorrect.

WHERE u.user_mail = user_mail

// Observations: if u.user_mail = user_mail are what relate a table and another, they are the ones that you have to use for the ON.

    
answered by 18.08.2017 в 17:51