I currently have a situation that could easily be solved with 3 SQL queries, but I wonder if it can be done in one query.

I have the following tables:

```
  symbol                     similarity
  -------                    ------------

  id | name | latex          id | base_symbol_id | similar_symbol_id

```

I want to SELECT so that my result looks like this:

```
  query_result
  ------------

  similarity_id | base_formula_id | base_formula_name | base_formula_latex | similar_formula_id | similar_formula_name | similar_formula_latex

```

Failed tries
------------

I usual solve similar tasks with JOIN. But this time, the SELECT depends on another attribute I select ... I don't know how to do this. Here is my try (which of course failed):

```
SELECT `base_symbol_id`, `similar_symbol_id`, `latex`
FROM `similarity` 
JOIN `symbol` ON ((`symbol`.`id` = `base_symbol_id`) OR (`symbol`.`id` = `similar_symbol_id`)) 

```

gives

```
base_symbol_id | simlar_symbol_id | latex
10             | 11               | \alpha
10             | 11               | a

```