Click here to Skip to main content
15,887,266 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I have two tables Tbl1 and tbl2, Tbl1 is master table and Tbl2 is support table. We need to fetch data from from Tbl1 with multiple SQL functions like (Contains, Like,..) on the behalf of Tbl2.

I am getting ordering only from Tbl2 to get the data from Tbl1.
1     Like
2     Contains
3     etc


Accroding to Tbl2 return, I need to perform query from Tbl 1. If I have "Like" first and "Contains" in 2nd. So my Query would be

SQL
Select * from Tbl1 where columnname   Like '%keyword%'
Union
Select * from Tbl1 where Contains( Columnname, '%keyword%')
Union
Select * from Tbl1 where etc....


If we make change column order in Tbl2 then Tbl1 should be change
1     Contains
2     Like
3     etc


Tbl1 Output -

SQL
Select * from Tbl1 where Contains( Columnname, '%keyword%')
Union
Select * from Tbl1 where columnname   Like '%keyword%'
Union
Select * from Tbl1 where etc....



Can anyone help me to write such types of query.
Posted
Updated 19-Oct-15 5:10am
v2
Comments
Suvendu Shekhar Giri 27-Oct-15 5:44am    
What is the problem here?
Why you want to change the sequence of UNION as it doesn't really matters for the result and if you want to change the order of the result sets, you can always do that using ORDER BY clause.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900