java - sql query to incrementally modify where condition until result contains what is required -


I need a SQL query to select some items from the table based on a condition that is based on the category field . Consider a list of people as an example and I bring people from a particular age group to the database. I want to check that at least one result from each of the categories in the result is the result. If I do not want to modify the age group by expanding it and check the result again. It is repeated until I get an age group for which there is a result for each category. Right now I am doing this by analyzing the result and modifying the SQL query. So many SQL selection queries are sent. What is the most effective way to do this? I am inviting select programs from the Java program using jdbc. I am using mysql database.

You need to create a processor or function according to your solution, your problem can easily be solved. Get processed GetPeople @ condition varchar (max) declared as @fiffight REC et SET @PermDefinition = N '@ cound nvarchar (max), @ cout int output'; Announce @@ query nvarchar (maximum) set @ query = 'select from people * where @cond; Set @cout = @@ rowcount 'exec @query EXECUTE sp_executesql @query, @permdfinition, @ condo = @ condition, @counting = disposedAcricut output; If @factreak & gt; 0 start return; Finally Android / update condition code APF People (Condition) End End


Comments