Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

SQL head ache

Status
Not open for further replies.

2cxc

Programmer
Aug 29, 2003
245
0
0
CA
Howdy! I'm having problems finishing my sql. The problem lies in incorporating the DINE_1 and DINE_2 values. These variables values are posted to the asp page with the cusine values. I'm trying to say at the end of the SQL that if either or both DINE_1 & DINE_2 values are true to select the records where column eat has DINE_1 or DINE_2.

This is my SQL so far:

Code:
theSQL = "SELECT * FROM logbook WHERE cusine IN ("
AFRICAN = Request.Form("AFRICAN")
If AFRICAN = "true" Then
 theSQL = theSQL & "'AFRICAN',"
End If
CARIBBEAN = Request.Form("CARIBBEAN")
If CARIBBEAN = "true" Then
 theSQL = theSQL & "'CARIBBEAN',"
End If
CHINESE = Request.Form("CHINESE")
If CHINESE = "true" Then
 theSQL = theSQL & "'CHINESE',"
End If
CONTINENTAL = Request.Form("CONTINENTAL")
If CONTINENTAL = "true" Then
 theSQL = theSQL & "'CONTINENTAL',"
End If
DUTCH = Request.Form("DUTCH")
If DUTCH = "true" Then
 theSQL = theSQL & "DUTCH',"
End If
EAST_INDIAN = Request.Form("EAST_INDIAN")
If EAST_INDIAN = "true" Then
 theSQL = theSQL & "'EAST_INDIAN',"
End If
ENGLISH = Request.Form("ENGLISH")
If ENGLISH = "true" Then
 theSQL = theSQL & "'ENGLISH',"
End If
ETHIOPIAN = Request.Form("ETHIOPIAN")
If ETHIOPIAN = "true" Then
 theSQL = theSQL & "'ETHIOPIAN',"
End If
FONDUES = Request.Form("FONDUES")
If FONDUES = "true" Then
 theSQL = theSQL & "'FONDUE',"
End If
FRENCH = Request.Form("FRENCH")
If FRENCH = "true" Then
 theSQL = theSQL & "'FRENCH',"
End If
FUSION = Request.Form("FUSION")
If FUSION = "true" Then
 theSQL = theSQL & "'FUSION',"
End If
GERMAN = Request.Form("GERMAN")
If GERMAN = "true" Then
 theSQL = theSQL & "'GERMAN',"
End If
GREEK = Request.Form("GREEK")
If GREEK = "true" Then
 theSQL = theSQL & "'GREEK',"
End If
ITALIAN = Request.Form("ITALIAN")
If ITALIAN = "true" Then
 theSQL = theSQL & "'ITALIAN',"
End If
JAPANESE = Request.Form("JAPANESE")
If JAPANESE = "true" Then
 theSQL = theSQL & "'JAPANESE',"
End If
JEWISH = Request.Form("JEWISH")
If JEWISH = "true" Then
 theSQL = theSQL & "'JEWISH',"
End If
KOREAN = Request.Form("KOREAN")
If KOREAN = "true" Then
 theSQL = theSQL & "'KOREAN',"
End If
MEDITERRANEAN = Request.Form("MEDITERRANEAN")
If MEDITERRANEAN = "true" Then
 theSQL = theSQL & "'MEDITERRANEAN',"
End If
MEXICAN = Request.Form("MEXICAN")
If MEXICAN = "true" Then
 theSQL = theSQL & "'MEXICAN',"
End If
MONGOLIAN = Request.Form("MONGOLIAN")
If MONGOLIAN = "true" Then
 theSQL = theSQL & "'MONGOLIAN',"
End If
PAKISTANI = Request.Form("PAKISTANI")
If PAKISTANI = "true" Then
 theSQL = theSQL & "'PAKISTANI',"
End If
PHILIPPINE = Request.Form("PHILIPPINE")
If PHILIPPINE = "true" Then
 theSQL = theSQL & "'PHILIPPINE',"
End If
PIZZA = Request.Form("PIZZA")
If PIZZA = "true" Then
 theSQL = theSQL & "'PIZZA',"
End If
PORTUGUESE = Request.Form("PORTUGUESE")
If PORTUGUESE = "true" Then
 theSQL = theSQL & "'PORTUGUESE',"
End If
RIBS = Request.Form("RIBS")
If RIBS = "true" Then
 theSQL = theSQL & "'RIBS',"
End If
STEAK_HOUSES = Request.Form("STEAK_HOUSES")
If STEAK_HOUSES = "true" Then
 theSQL = theSQL & "'STEAK_HOUSES',"
End If
THAILAND = Request.Form("THAILAND")
If THAILAND = "true" Then
 theSQL = theSQL & "'THAILAND',"
End If
UKRAINIAN = Request.Form("UKRAINIAN")
If UKRAINIAN = "true" Then
 theSQL = theSQL & "'UKRAINIAN',"
End If
VEGETARIAN = Request.Form("VEGETARIAN")
If VEGETARIAN = "true" Then
 theSQL = theSQL & "'VEGETARIAN',"
End If
VIETNAMESE = Request.Form("VIETNAMESE")
If VIETNAMESE = "true" Then
 theSQL = theSQL & "'VIETNAMESE',"
End If
WEST_INDIAN = Request.Form("WEST_INDIAN")
If WEST_INDIAN = "true" Then
 theSQL = theSQL & "'WEST_INDIAN'"
End If
theSQL = left( theSQL, len(theSQL)-1 )
theSQL = theSQL & ") AND eat IN ('BOTH')"

so far i have where eat db value = both, i'm trying to narrow down to records where DINE_1 and DINE_2 values sent to this asp page are true.
 
This doesn't look like TSQL (MS SQL Server's language) to me. Are you using MS SQL Server or another SQL database?

If it's not SQL Server, you need to post your question in the proper forum.

-SQLBill

SELECT 'forum' CASE [SQL TYPE]
WHEN 'MySQL' THEN 'forum436'
WHEN 'Access' THEN 'forum700', 'forum701', 'forum702', 'forum703', 'forum704', 'forum181'
WHEN 'ORACLE' THEN 'forum185' 'forum186', 'forum759'
 
I guess your code is a sort of pseudo-ASP code: constructing an SQL statement via APS code, but you removed the annoying <% and %> tags :)

I don't completely understand your question, but my guess is you have to change:

theSQL = theSQL & &quot;) AND eat IN ('BOTH')&quot;

to

theSQL = theSQL & &quot;) OR eat IN ('BOTH')&quot;
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top