SQL OleDBCommand selecting Excel Columns

2019-09-18 01:20发布

问题:

I'm using OleDBCommand to select some data in an Excel sheet I have. I have One column that has lists of data (column J) and every column after that either (columns K - AG) has a 1 or 0 depending on a relationship. So it's basically a graph plotted with 1 or 0. I want to use a SQL command to select every entry in column J where there is a 1 plotted in a column I choose. For example, say I want to look at the column J to K relationship. Then I would want to pull all data from J where columns J and K have a 1. I am unsure of how to specify columns in SQL. I have currently:

OleDbCommand command = new OleDbCommand("select * from [Master$J0:J20] , connection);

I would need a WHERE clause after that to specify, where K0:K20 = '1' right? Or something like that. I can't get it.

回答1:

Solution: Columns can be referenced by F1, F2, F3...FN. So in my case I would want for example:

SELECT F8 FROM [Sheet1$] WHERE F11 = '1'