if I was to assign a string variable to Elvis Presley, what would your example above look like using a string variable?
Yes, what you shown was correct. Except don't forget the concatenation symbols (ie. '+' or '&' )
stringvariableA = "Elvis Presley"
WHERE UPPER(Question) LIKE UPPER('%" + stringvariableA + "%')
the 2nd thing is:
if I am understanding you correctly, the command { UPPER(Question) } indicates the column that you want to look in.
So if I wanted to look in answer the command would be { UPPER(Answer) } ?
Yes, you are correct about that. I will say this though. You can get an entire row of data by querying one entry by using the asterisk '*':
SELECT * FROM table WHERE column LIKE %entry%
the * symbol means that you will return all the columns in the table on the same row as the entries were found.
For instance, if you have a table that looks like this:
<Column 0> <Column 1> <Column 2> <Column 3>
Question | answer | timestamp | location
----------------------------------------------------------------------
how are you | I am fine | 5:00PM | park <row 0>
do you eat | yes I do | 6:00PM | zoo <row 1>
Now lets say I look for any question with the word 'eat'. And lets say that I want to know what time that question was asked. I would want to recall only two columns, Question and timestamp. (I could select all columns with the * symbol but I just want two)
SELECT Question, timestamp
Lets now search for the entry with the 'eat' search word in it.
SELECT Question, timestamp FROM QA_table WHERE Question LIKE '%eat%'
So now a table array will be returned with our answers.
Dim returnArray
So what exactly is in the returnArray?
What's in the array are two columns (Question and timestamp) and one row: it looks something like this:
<Column 0> <Column 1>
Question | timestamp |
------------------------------------
do you eat | 6:00PM | <row 0>
So now we retrieve that information from the returnArray.
Entry = returnArray(row, column)
or
Time1 = returnArray(0, 1) 'this will return 6:00PM
Question1 = returnArray(0, 0) 'this will return 'do you eat'
If we wanted to return the entire <row 0> then we would write it like this:
SELECT * FROM QA_table WHERE Question LIKE '%eat%'
You would return this:
<Column 0> <Column 1> <Column 2> <Column 3>
Question | answer | timestamp | location
----------------------------------------------------------------------
do you eat | yes I do | 6:00PM | zoo <row 0>
So you could get the answer, timestamp, and location for the question you asked.
what is the easiest way to divide the words in a sentence?
You use the Split() command to do this.
array1 = Split("a chick can run fast", " ", -1, vbTextCompare)
array1(0) ' = a
array1(1) ' = chick
array1(2) ' = can
array1(3) ' = run
array1(4) ' = fast
array2 = Split("a##dog##can##run##faster", "##", -1, vbTextCompare)
array2(0) ' = a
array2(1) ' = dog
array2(2) ' = can
array2(3) ' = run
array2(4) ' = faster
ynlogic0 = "Fred is my friend. Who is Fred?"
array3 = Split("Fred is my friend. Who is Fred?", ".", -1, vbTextCompare)
If Ubound(array3) = 2 Then
ynlogic1 = array3(0)
ynlogic2 = array3(1)
End If
But my question is: can this command structure be used to search through: for instance in your example: { Dim returnArray() }
No. The HalBrain.QABrain() will not work that way. In order to use it, you would have to make a new table using the returnArray and then you could use the HalBrain.QABrain() function on that new table. Another thing you could do is to rate the returnArray yourself. You would do this by looping through the array and finding entries that better suit your needs. There are a lot of ways to do this.