Query by data of another MySQL table

1

I have a question, I want to know if it is possible to consult a data of a table and compare it with another data of another table, I mean, I have a table table which has its id, and another table which has as FK the id of the table of the previous table, my query is, can you perform the following query ?:

SELECT Id FROM mesa WHERE Id = pedido.Id_mesa

If possible please correct me if the query is wrong, I would appreciate it very much.

Greetings!.

    
asked by Pedro 10.11.2018 в 17:33
source

1 answer

0

You have to indicate in the FROM all the tables that you are going to integrate and then if you can do the conditional with the different tables.

SELECT m.id FROM mesa m, pedido p WHERE m.id = p.id;
    
answered by 10.11.2018 в 18:01