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!

Nested SQL Statement

Status
Not open for further replies.

jreinard

Technical User
Feb 21, 2001
24
0
0
US
I have 2 search functions written in ASP that call from different fields in a SQL 7 database. One is an item number search and the other is a basic "like" query. I am now trying to merge the 2 so I have one big search feature. The problem I am having is nesting the 2 SQL statements. It seems that everything I try does not work. As you can see from the code below, these 2 statements are somewhat different. The basic query has a restriction based off of a parent item so it will not return anything that has a parent item. If anyone has any thoughts on this, please let me know....

Thanks in advance!


// item number search

SELECT NO, DESCRIPTION, WEBNAME, UNITPRICE
FROM SHOP_ITEM
WHERE NO LIKE '%" & Request.Form("searchvalue") & "%'
ORDER BY NO"


// Basic Query

SELECT NO, DESCRIPTION, WEBNAME, UNITPRICE
FROM SHOP_ITEM
WHERE WEBDESCRIPTION LIKE '%" & Request.Form("searchvalue") & "%' AND PARENTITEM = ' '
ORDER BY NO"


 
SELECT NO, DESCRIPTION, WEBNAME, UNITPRICE
FROM SHOP_ITEM
WHERE (WEBDESCRIPTION LIKE '%" & Request.Form("searchvalue") & "%' AND PARENTITEM = ' ' ) or NO LIKE '%" & Request.Form("searchvalue") & "%'
order by no
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top