How to make the union of tables in the database

0

Try to join the tables but you can not here the code of the sentence

$consulta = "SELECT * FROM usuario AS u, materiales AS m WHERE ";
  $resultado = $conexion->query($consulta) OR DIE("Error al Ejecutar Consulta de Usuario y Materiales".mysqli_error($conexion)  );

Image of the User Table

Image of the Table of Materials

    
asked by Gamez 28.05.2017 в 22:16
source

1 answer

0

I understand that you want a natural product between the table usuario and the table materiales , so I saw in your table users has a column called materials on that column you must do inner join , as follows:

SELECT * FROM usuario INNER JOIN materiales ON usuario.materiales=materiales.idMateriales

If you want to add a condition, just put the where at the end of the sentence above and remember that you must specify on which table you want to do the where for example:

... where usuarios.id=[lo que busques]
    
answered by 29.05.2017 в 01:31