dcsimg
sql query problem
1 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Alok_Dharia
Posted On:   Tuesday, August 3, 2004 10:10 AM

hi i am new to programming world and i am using [B]db2[/B] as my back hand now the problem is that i am making a website which has list of 5 menu box and each menu box has 3 choice viz for eg a menu box called RAM will have choice like 128mb , 256 mb , 'ALL' 'All' means that i have to get all the available values of ram from my database now i am dynamically allowing user to chose the ram , and from other menu box too now my output will be generated according to the menu item selected so my query is tring process = "SELECT P.PRICE,P.TYPE,P.MODEL,P.RAM, FROM DHARIA.REFURBISH P where P.TYPE = '"+t+"' and p.model = '"+m+"' and p.ram = '"+r+"'    More>>
			hi i am new to programming world and i am using [B]db2[/B] as my back hand
			

now the problem is that i am making a website which has list of 5 menu box
and each menu box has 3 choice viz for eg a menu box called RAM will have choice like 128mb , 256 mb , 'ALL'

'All' means that i have to get all the available values of ram from my database


now i am dynamically allowing user to chose the ram , and from other menu box too

now my output will be generated according to the menu item selected

so my query is

tring process = "SELECT P.PRICE,P.TYPE,P.MODEL,P.RAM, FROM DHARIA.REFURBISH P where P.TYPE = '"+t+"' and p.model = '"+m+"' and p.ram = '"+r+"' "


see here t , m ,r are the variables which stored the selected value from the menu list

now the query works fine as long as i chose some value from my menu box but

when i chose "ALL" from any one of the menu list the query does not work because then the variable say for eg 't' is assigned ALL value and when trhe query is executed p.type tries to matches with 'ALL' and since all is not there in my database it wont give me the answer

wht i want is that whn u chose 'all' we should get every thing of that particular column

plz help me i have to give it urgetn
   <<Less

Re: sql query problem

Posted By:   Simon_Ablett  
Posted On:   Tuesday, August 3, 2004 10:30 AM

You could build your query dynamically such that the component of the 'WHERE' clause for each field is only included if that field is not to refer to all of its values. Alternatively, when 'all' is selected, set the value for that field to the SQL wildcard i.e. '%'.

Regards.
About | Sitemap | Contact