There is a cats table and a sales table.
sales stores offers (id, need, ican) , and cats (id, need, ican) description of offers (id, title) . sales in need and ican write the id values from cats .
Cats:
id| title ----------------- 1 | уборка дома 2 | ремонт машины 3 | мойка окон Sales:
id|need|ican ------------ 1 | 2 | 1 2 | 3 | 3 3 | 1 | 3 It is necessary to bring sales tied to it cats taking from there the title to need and ican.
We construct the query:
SELECT sales.id AS sales_id, cats.title AS cats_title FROM sales, cats WHERE sales.need = cats.id AND sales.ican = cats.id In the end - empty, no answer.
The question is whether it is possible to output both need and ican with this one query, can use ican , is there a more efficient way?