Forums

ASP

This topic is locked

sql query, adding variables syntax

Posted 15 Jan 2004 01:18:27
1
has voted
15 Jan 2004 01:18:27 richard thomas posted:
Hi,
I wish to add additional variables to the following peice of search code:

<code>

Dim Var1

Var1 = ("P"

Dim nameRS
Set RS1 = Conn.Execute("Select NAME FROM TABLE1 WHERE TABLE1.REF = '" & (Var1) & "' "

</code>

This works fine, but I wish to add another variable, such as:

<code2>

Dim Var1, Var2
Var1 = ("P"
Var2 = ("Q"

Dim nameRS
Set RS1 = Conn.Execute("Select NAME FROM TABLE1 WHERE TABLE1.REF = '" & (Var1) & "' OR '" & (Var2) & "' "

</code2>

This doesn't include the additional Var2 in the search results and causes 'odd' search results. Is this syntax. Just to recap, code example 1 works but I just need to add an additional variable and include it in the search parameters.

Thanks in advance.

Replies

Replied 18 Jan 2004 17:17:27
18 Jan 2004 17:17:27 Phil Shevlin replied:
Set RS1 = Conn.Execute("Select NAME FROM TABLE1 WHERE TABLE1.REF = '" & (Var1) & "' OR TABLE1.REF = '" & (Var2) & "' "

Replied 19 Jan 2004 12:32:04
19 Jan 2004 12:32:04 richard thomas replied:
Thnaks very much, that works a treat.

Reply to this topic