I have 2 indexes, indexA
and indexB
. There 2 indexes have different columns.
Example:
Index A:
+---+-----+
|id |text |
+---+-----+
|1 |john |
|2 |tom |
|3 |sam |
+---+-----+
Index B:
+---+---------+-----+
|id |parentid |num |
+---+---------+-----+
|1 |1 |64 |
|2 |1 |128 |
|3 |2 |256 |
+---+---------+-----+
Question:
How do I get result like this?
/*Client search*/
SELECT
A.id, A.text, B.num
FROM
indexa A
INNER JOIN
indexb B ON A.id = B.parentid
WHERE
B.num > 100
Result:
+-----+--------+-------+
|A.id | A.text |B.num |
+-----+--------+-------+
|1 |john |128 |
|2 |tom |256 |
+-----+--------+-------+
After edit index query, problem solved.
Solved index query:
SELECT
A.id,A.text,B.num
FROM
tableA A
LEFT JOIN
tableB B ON A.id=B.parentid
Search query:
SELECT * FROM indexA