Can an INNER JOIN be done with a WHERE?

1

I get an error, it's a sure formulation error, but I can not find it

SELECT * FROM comentariosforo WHERE ID_Post = '$IDPost'
INNER JOIN usuarios
ON usuarios.ID = comentariosforo.ID_Persona
    
asked by JuamBer 17.06.2018 в 14:39
source

1 answer

1

I'll give you the following example so you can adapt it according to your needs.

Imagine that I have 2 tables; a call users and another call posts, where I keep the id of the user who made each posts; then at the end I want with a JOIN to get all the posts that correspond to the user with id 3

SELECT title, body, username 
FROM usuarios
INNER JOIN posts
ON usuarios.id = posts.usuario_id
WHERE usuarios.id = $usuario_id;
  

As notes if I use the WHERE but at the end of the query, then   first you need to perform the JOIN as well as indicate which field in   The union of both tables is fulfilled

    
answered by 17.06.2018 / 14:47
source