这是我的查询:
$query = "SELECT t1.one_field,t2.another_field FROM table_one t1,
table_two t2 WHERE t2.flag = 2 AND (t1.id = t2.id1 OR t1.id = t2.id2)
AND (t2.id1 = '$comparison' OR t2.id2 = '$comparison') LIMIT 1";
我尝试使用GROUP BY,DISTINCT,UNIQUE(...)但却无法提取我想要的内容......我总是提取 another_field 和一个 one_field 而不是两个 one_field ......完成此任务的最佳方式是什么? Tyvm ...
one_field | id
example1 | id_example1
example2 | id_example2
another_field | flag | id1 | id2
need_to_get | 2 | id_example1 | id_example2
example1, example2, need_to_get (don't care if result is array or associative)
example2, need_to_get (expected, since one of the results gets overridden since it has the same field_name...)