Answer the question
In order to leave comments, you need to log in
How to get one field data from two mysql tables?
There is a `messages` table with an id (message id) field and a `users` table with an id (user id) field. How to get data from two tables. My attempt:
I get:
ERROR 1052 (23000): Column 'id' in field list is ambiguous
SELECT id FROM `messages`,`money_box`;
Answer the question
In order to leave comments, you need to log in
SELECT
`messages`.`id` AS `messages_id`, `money_box`.`id` AS `money_box_id`
FROM `messages`,`money_box`;
the problem is that as a result the id is from both tables, therefore a conflict is obtained,
and it can also be misunderstood with such a query, it is better to use join
SELECT
`messages`.`id` AS `messages_id`, `money_box`.`id` AS `money_box_id`
FROM `messages` JOIN `money_box`
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question