简体   繁体   中英

Operator IN VBA excel

Could you help me please? I have tried to solve my problem for about 6 hours. I have one table and there are 4 columns.

Columns: Nio ,checked,date,time

I need to get data from the first and second columns, where I have to compare it by date and time.

I wanted to use the operator IN but excel gives me the error

Incorrect syntax near the keyword

Thanks for help.

strQueryQ7DrLeftElox = 
"((Select nio,checked 
FROM q7_dr_left_elox_incoming_inspection 
where date >= '" & sDateFrom & "' AND date <= '" & sDateTo & "') IN   (Select nio,checked from q7_dr_left_elox_incoming_inspection WHERE time = '19:55:06'))"

Both select statements query the same table, so simplify it by adding one more condition in the 1st query's WHERE clause:

SELECT nio,checked 
FROM q7_dr_left_elox_incoming_inspection 
WHERE date >= '" & sDateFrom & "' AND date <= '" & sDateTo & "'
AND time = '19:55:06'

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM