Hello. How to use JOIN ?. In the internet I did not find a clear and intelligible description. There are two tables:

1) authors (authors) with fields:

 `author_id` (auto increment), `fio`, `e-mail`, `his_password`, `raiting`. 

2) articles (articles) with fields:

 `article_no` (auto increment), `author_id`, `title`, `text`. 

When a php script takes an article from the second table according to its article_no (it is transmitted in the page address using the GET method), it should also receive the author’s full name and rating from the first table. This can be done in two queries:

 $query1 = mysql_query ("SELECT `author_id`, `title`, `text` FROM `articles` WHERE `article_no` = '$article_no_from_get'"); $result1 = mysql_fetch_array ($query1) $query2 = mysql_query ("SELECT `fio`, `raiting` FROM `authors` WHERE `author_id` = '$result1 [author_id]'"); 

However, it would be more rational to merge these two queries into one using a JOIN. How to do it?

Sincerely, V. Ivanov

    2 answers 2

     SELECT articles.author_id, articles.title, articles.text, authors.fio, authors.raiting FROM articles JOIN ON articles.author_id=authors.author_id WHERE articles.article_no = '$article_no_from_get' 

    Something like this, if I'm not mistaken

      Read about join in the wiki , where basic things are considered on simple examples.