简体   繁体   中英

Need help to build query

I am trying to write logic for advanced search which has lot of fields. Based on user inputs I have to build the query dynamically. The oracle query has exists clause also.

At present I have a chain of switch cases which helps me in forming the query. But this has become very complex procedure, editing the logic to build a query has become very difficult.

Other than switch case is there any other way to build query dynamically. Please let me know

Just generic suggestion adding 1=1 in where clause makes thing easier.
This might help Why would someone use WHERE 1=1 AND <conditions> in a SQL clause?
PS: Also update your question with specific problem otherwise it is very likely to be get closed.

There is EasyQuery ( http://devtools.korzh.com/easyquery/ ) solution but it's implemented for ASP.NET as far as I know. However, they have a jQuery-based client-side library which could be useful in your case.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM