Home > database >  Three millions of data table select related queries
Three millions of data table select related queries

Time:09-23

A, B, C three tables, each table around 2.4 million data, the current situation, can't new field, new table, you can't use the trigger ,

A table field status, type,
The status 0, associated table B,
The status 1, associated C table,

B, C table each have a field identification data is valid,

Demand at present: A table data paging query, B, C, according to the invalid data will not be and statistical type

Problems at present: A paging query cannot judge the associated table B, C table data is valid, lead to page 10, article 9 invalid data, shows the current page points 1, and the statistical error, the number of the type

CodePudding user response:

B and C on the table, and A relationship with field index,
The SELECT A.T YPE FROM WHERE A
NOT the EXISTS (SELECT 0 FROM B WHERE A.S TATUS=0 AND B, AND A correlation) AND
NOT the EXISTS (SELECT FROM 0 C WHERE A.S TATUS=1 AND C AND A correlation)
The ORDER BY A.T YPE
LIMIT 1, 10;
  • Related