|
-
Query statement assistance
I am new to SQL so please bare with me.
What I am tring to achieve is a SQL query that displays results based on one category in which the rest of the query will display results based on the initial category or group. The initial category is a drop down box. Then from there I created a navigation menu with radial button in which refines the search.
For example this is the drop down selections:
dim unitquery as string
if (unit.text = "ALL Model Years" ) then
unitquery = "[Auto_year] BETWEEN" & chr(39) & "1970" & chr(39) & "AND" & chr(39) & "2005" & chr(39)
else if (unit.text = "Mustang Only" )
unitquery = "[model]= 'Mustang' "
else if (unit.text = "Ranger Only" )
unitquery = "[model]= 'Ranger' "
else if (unit.text = "Ranger Only" )
unitquery = "[model]= 'Explorer' "
End if
strSearch = gen.Text
dbcommand = New SqlDataAdapter( "SELECT model, color, engine, navgtn_sys, timestamp " _
& "FROM tbl_name " _
& "WHERE ( " & unitquery & ") AND model LIKE '%" & Replace(strSearch, "'", "''") & "%'" _
& "OR color LIKE '%" & Replace(strSearch, "'", "''") & "%'" _
& "OR engine LIKE '%" & Replace(strSearch, "'", "''") & "%'" _
& "OR navgtn_sys LIKE '%" & Replace(strSearch, "'", "''") & "%'",bcon )
What happens is the farther the query is refined it displays all models not just Mustang or Ranger. This is an example not the actual data I am seeking.
Any ideas where I can improve on this query string to seperate the queries by model as the search is refined?
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
Forum Rules
|
Top DevX Stories
Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL
|
Bookmarks