2

Given the following connection to an SQL query works but the data comes out wrong:

data = Table[SQLSelect[conn, "All", {"col1", "col2"}, 
   SQLColumn["col1"] == n && SQLColumn["col2"] ==  o], {n, 1, 8}, {o, 21,
    30}];

If I do not use the 'Table' function, I get the expected results by inserting the actual numbers after == when running the query. I need to create a 54 x 289 table from my data and obviously for this large data set this will be impractical to key in and export piece by piece.

Any suggestions?

C. E.
  • 70,533
  • 6
  • 140
  • 264
Sinistar
  • 1,029
  • 1
  • 10
  • 19
  • 2
    Try this data = SQLSelect[conn, "All", {"col1", "col2"}, SQLMemberQ[Range@8, SQLColumn["col1"]] && SQLMemberQ[Range[21, 30], SQLColumn["col2"]]]; – Dr. belisarius Mar 20 '14 at 05:22
  • I can't test it, will post as an answer if it works – Dr. belisarius Mar 20 '14 at 14:15
  • Much better! I had to increase the Java heap size for jDBC (I went from 3GB to 4GB). It executed many many times faster . I think I still have a logic problem telling the query which rows to select but this is a step in the right direction! Thanks! – Sinistar Mar 20 '14 at 14:49
  • When you come to solve it, post it as an answer and ping me to upvote – Dr. belisarius Mar 20 '14 at 15:40
  • I think we can offer your post as an answer. It does do what I asked. I just need to refine my question for the results I was desiring. I upvoted your suggestion. Where did that confounded mark as answer button go? – Sinistar Mar 20 '14 at 17:18

1 Answers1

1

Try this

data = SQLSelect[conn, "All", {"col1", "col2"}, 
                 SQLMemberQ[Range@8, SQLColumn["col1"]] && 
                 SQLMemberQ[Range[21, 30], SQLColumn["col2"]]];
Dr. belisarius
  • 115,881
  • 13
  • 203
  • 453