Skip to content
Advertisement

single or multiple search with a single query based on condition

For example i have this table component_information with these atrribute

I will pass the group_code,category_code,compnent_code from the frontend for searching.Now i want to do single or multiple search based on this. Like on first condition if it gets only group_code value from frontend it will do search only based on group_code.On second condition,If it gets group_code and category_code then it will do multiple search ignore the first condition and so on.But my query only returning value for first condition only even if it gets multiple value.Is there any way to do it in a single query or i have to write separate query for every condition>here is what i have done so far

Advertisement

Answer

You are having a generic SQL statement with multiple OR conditions. I would suggest you to dynamically construct the SQL Statement based on request arguments.

User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement