Click here to Skip to main content
15,898,134 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hi friends,
I need help in my DB,i wanna convert a UNION Query Into Join Query.PlZ help me in this task.how can i convert that..............?

Two tables Table1 and Table2.One common field(userID) in both tables.two condition for searching(fullname like'%ab%') and (companyname like '%ab%').
Posted

As per I understood your problem I can conclude below solution.

SELECT * FROM Table1 T1 INNER JOIN Table2 T2 ON T1.userID = T2.userID
WHERE fullname LIKE '%ab%' AND companyname like '%ab%'


Please vote and Accept Answer if it Helped.
 
Share this answer
 
Comments
PRADEEPPEDNEKAR 5-Oct-10 7:59am    
Thanks bro.But i want to bring the searched things(columns) in a order first its should display fullname details then companyname details
Hiren solanki 5-Oct-10 8:09am    
you can have this columns selection inside select statement.
<pre lang="sql">SELECT designation,fullname,company_name,country, FROM(SELECT fullname,company_name,designation,country, Row_number() OVER (ORDER BY fullname DESC) RowNum FROM (SELECT P.fullname,P.company_name, P.designation, P.country FROM People AS P inner JOIN Company AS C ON P.company_id = C.company_id WHERE ((P.fullname like 'a%') and )or(C.company_name like 'a% )GROUP BY P.fullname,P.company_name,P.designation,P.country, ) t) t1 WHERE RowNum BETWEEN (0*25+1) AND ((2+1)*25)




this is my query
it is giving me out put in jumbled format.
I need it in proper format.
Full name with 'a%' all columns and then companyname with 'a%'.
out put should be in this format
FUll name companyname
aabbc cccccc
abcc sssss
ab sssbshjhsj
ddfdfd aaabbbbaa
eryeyruy aabbbdd
ruhj ahfhff




Plz friends help me in this query.
 
Share this answer
 

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