0

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    |
+-----+--------+-------+
marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
King Max
  • 45
  • 2
  • 6

1 Answers1

0

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
King Max
  • 45
  • 2
  • 6