1. database: MySQL
2. table_1 includes 5000 records.
table_1_id, create_date, status
3. table_2 includes 20 million records
table_2_id, table_1_id, user_id
4. 我的问题是要 找出记录table_1 , 中,
SELECT * FROM table_1 WHERE CREATE_DATE > SOMEDATE AND STATUS =' 2'
并且, table_2 不包含 table_1_id 且 user_id <>'abc'. 怎么做好, 不太想用兵NOT IN
5. 我是这么做的
a. rs1= SELECT * FROM table_1 WHERE CREATE_DATE > SOMEDATE AND STATUS =' 2'
b. LOOp result from a
for example. like
while (rs1 ...) {
rs2 = select * from table_2 where table_1_id= result1.table_1_id and name='abc'
if (rs2..) {
print '不是需要的'
} else {
//print 找到记录
}
}
6. 是不是,有更好的办法, 多谢了
2. table_1 includes 5000 records.
table_1_id, create_date, status
3. table_2 includes 20 million records
table_2_id, table_1_id, user_id
4. 我的问题是要 找出记录table_1 , 中,
SELECT * FROM table_1 WHERE CREATE_DATE > SOMEDATE AND STATUS =' 2'
并且, table_2 不包含 table_1_id 且 user_id <>'abc'. 怎么做好, 不太想用兵NOT IN
5. 我是这么做的
a. rs1= SELECT * FROM table_1 WHERE CREATE_DATE > SOMEDATE AND STATUS =' 2'
b. LOOp result from a
for example. like
while (rs1 ...) {
rs2 = select * from table_2 where table_1_id= result1.table_1_id and name='abc'
if (rs2..) {
print '不是需要的'
} else {
//print 找到记录
}
}
6. 是不是,有更好的办法, 多谢了