Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
pkuchaliya
Starting Member
49 Posts |
Posted - 2008-07-09 : 10:25:23
|
I m facing the problem to extract the values from table.i have three table:create user_detail(id varchar(50),name varchar(50),location_from varchar(max), job_type varchar(max))create locationfrom(id varchar(50),type varchar(50))create jobtype(id varchar(50), type varchar(50))values in these tables:-insert into user_detail values('101','pankaj','101,102,103','101,102,103')insert into locationfrom values('101','delhi')insert into locationfrom values('102','bombay')insert into locationfrom values('103','madras')insert into jobtype values('101','Agent')insert into jobtype values('102','account')insert into jobtype values('103','Bussiness')Now i have to make a query which will display the output from user_detail table like:-pankaj,delhi-bombay-madras,agent-account-bussinessPlease help me i need it urgent.Plzzzzzzzzzzzzzzzzz pankaj |
|
|
Transact Charlie
Master Smack Fu Yak Hacker
3451 Posts |
Posted - 2008-07-09 : 11:19:59
|
quote: I m facing the problem to extract the values from table.
I'm not surprised, joining these tables together is a nightmare... Can you change the schema at all?This will give you a normalised table but performance will be terrible...SELECT ud.[name] AS [name] , lf.[type] AS [location] , jt.[type] AS [Jobtype]FROM user_detail ud JOIN locationFrom lf ON ud.[location_from] LIKE '%' + lf.[Id] + '%' JOIN jobType jt ON ud.[job_type] LIKE '%' + jt.[Id] + '%' results in.....name,location,Jobtypepankaj,delhi,Agentpankaj,bombay,Agentpankaj,madras,Agentpankaj,delhi,accountpankaj,bombay,accountpankaj,madras,accountpankaj,delhi,Bussinesspankaj,bombay,Bussinesspankaj,madras,Bussiness-------------Charlie |
 |
|
|
pkuchaliya
Starting Member
49 Posts |
Posted - 2008-07-10 : 00:03:47
|
Hi Charlie,Thanks for the reply, I run this query this results multiple rows . As you suggest to change the schema, Will u please tell me that what will be the better way.can i break the user_detail table to :-user_detail(id varchar(50),name varchar(50)):-user_detail_location(id varchar(50) ,location_from varchar(max)):-user_detail_job_type(id varchar(50) ,job_type varchar(max))Is it right way, if any better solution possible then please help.and thanks.quote: Originally posted by Transact Charlie
quote: I m facing the problem to extract the values from table.
I'm not surprised, joining these tables together is a nightmare... Can you change the schema at all?This will give you a normalised table but performance will be terrible...SELECT ud.[name] AS [name] , lf.[type] AS [location] , jt.[type] AS [Jobtype]FROM user_detail ud JOIN locationFrom lf ON ud.[location_from] LIKE '%' + lf.[Id] + '%' JOIN jobType jt ON ud.[job_type] LIKE '%' + jt.[Id] + '%' results in.....name,location,Jobtypepankaj,delhi,Agentpankaj,bombay,Agentpankaj,madras,Agentpankaj,delhi,accountpankaj,bombay,accountpankaj,madras,accountpankaj,delhi,Bussinesspankaj,bombay,Bussinesspankaj,madras,Bussiness-------------Charlie
pankaj |
 |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2008-07-10 : 00:07:46
|
this is much better. user_detail(id varchar(50),name varchar(50))user_detail_location(id varchar(50) ,location_from varchar(max))user_detail_job_type(id varchar(50) ,job_type varchar(max)) Change the max to 50. Your location & job_type is only varchar(50) KH[spoiler]Time is always against us[/spoiler] |
 |
|
|
pkuchaliya
Starting Member
49 Posts |
Posted - 2008-07-10 : 03:46:20
|
| hi khtan,i have write the query:-select nkjob.job_id,nkjob.employer_profile_id,nkjob.designation,nkjob.key_skill,ncity.city_name,nfarea.functional_type ,nkinds.industry_type,nspcl.specialization_type from nk_employer_post_job_ nkjobjoin nk_city_ ncity on nkjob.job_location like '%'+ncity.city_id+'%'join nk_fuctional_area_ nfarea on nkjob.functional_area like '%'+nfarea.functional_id+'%'join nk_industry_type_ nkinds on nkjob.type_of_industry like '%'+nkinds.industry_id+'%'join nk_specialization_ nspcl on nkjob. area_of_specialization like '%'+nspcl.specialization_id+'%' and i got the output like this :-PANJOB000000000001 pankaj Sr. Devp asp.net,c# New Delhi Agent Accounting/Taxation/Finance SystemPANJOB000000000001 pankaj Sr. Devp asp.net,c# Mumbai Agent Accounting/Taxation/Finance SystemPANJOB000000000001 pankaj Sr. Devp asp.net,c# New Delhi Agent Accounting/Taxation/Finance ComputersPANJOB000000000001 pankaj Sr. Devp asp.net,c# Mumbai Agent Accounting/Taxation/Finance ComputersPANJOB000000000001 pankaj Sr. Devp asp.net,c# New Delhi Banking/Insurance Accounting/Taxation/Finance SystemPANJOB000000000001 pankaj Sr. Devp asp.net,c# Mumbai Banking/Insurance Accounting/Taxation/Finance SystemPANJOB000000000001 pankaj Sr. Devp asp.net,c# New Delhi Banking/Insurance Accounting/Taxation/Finance ComputersPANJOB000000000001 pankaj Sr. Devp asp.net,c# Mumbai Banking/Insurance Accounting/Taxation/Finance ComputersPANJOB000000000001 pankaj Sr. Devp asp.net,c# New Delhi IT Software - Client Server Accounting/Taxation/Finance SystemPANJOB000000000001 pankaj Sr. Devp asp.net,c# Mumbai IT Software - Client Server Accounting/Taxation/Finance SystemPANJOB000000000001 pankaj Sr. Devp asp.net,c# New Delhi IT Software - Client Server Accounting/Taxation/Finance ComputersPANJOB000000000001 pankaj Sr. Devp asp.net,c# Mumbai IT Software - Client Server Accounting/Taxation/Finance ComputersPANJOB000000000001 pankaj Sr. Devp asp.net,c# New Delhi IT Software - Mainframe Accounting/Taxation/Finance SystemPANJOB000000000001 pankaj Sr. Devp asp.net,c# Mumbai IT Software - Mainframe Accounting/Taxation/Finance SystemPANJOB000000000001 pankaj Sr. Devp asp.net,c# New Delhi IT Software - Mainframe Accounting/Taxation/Finance ComputersPANJOB000000000001 pankaj Sr. Devp asp.net,c# Mumbai IT Software - Mainframe Accounting/Taxation/Finance ComputersPANJOB000000000001 pankaj Sr. Devp asp.net,c# New Delhi IT Software - Middleware Accounting/Taxation/Finance SystemPANJOB000000000001 pankaj Sr. Devp asp.net,c# Mumbai IT Software - Middleware Accounting/Taxation/Finance SystemPANJOB000000000001 pankaj Sr. Devp asp.net,c# New Delhi IT Software - Middleware Accounting/Taxation/Finance ComputersPANJOB000000000001 pankaj Sr. Devp asp.net,c# Mumbai IT Software - Middleware Accounting/Taxation/Finance ComputersPANJOB000000000001 pankaj Sr. Devp asp.net,c# New Delhi Agent BPO/ITES/CRM/Transcription SystemPANJOB000000000001 pankaj Sr. Devp asp.net,c# Mumbai Agent BPO/ITES/CRM/Transcription SystemPANJOB000000000001 pankaj Sr. Devp asp.net,c# New Delhi Agent BPO/ITES/CRM/Transcription ComputersPANJOB000000000001 pankaj Sr. Devp asp.net,c# Mumbai Agent BPO/ITES/CRM/Transcription ComputersPANJOB000000000001 pankaj Sr. Devp asp.net,c# New Delhi Banking/Insurance BPO/ITES/CRM/Transcription SystemPANJOB000000000001 pankaj Sr. Devp asp.net,c# Mumbai Banking/Insurance BPO/ITES/CRM/Transcription SystemPANJOB000000000001 pankaj Sr. Devp asp.net,c# New Delhi Banking/Insurance BPO/ITES/CRM/Transcription ComputersPANJOB000000000001 pankaj Sr. Devp asp.net,c# Mumbai Banking/Insurance BPO/ITES/CRM/Transcription ComputersPANJOB000000000001 pankaj Sr. Devp asp.net,c# New Delhi IT Software - Client Server BPO/ITES/CRM/Transcription SystemPANJOB000000000001 pankaj Sr. Devp asp.net,c# Mumbai IT Software - Client Server BPO/ITES/CRM/Transcription SystemPANJOB000000000001 pankaj Sr. Devp asp.net,c# New Delhi IT Software - Client Server BPO/ITES/CRM/Transcription ComputersPANJOB000000000001 pankaj Sr. Devp asp.net,c# Mumbai IT Software - Client Server BPO/ITES/CRM/Transcription ComputersPANJOB000000000001 pankaj Sr. Devp asp.net,c# New Delhi IT Software - Mainframe BPO/ITES/CRM/Transcription SystemPANJOB000000000001 pankaj Sr. Devp asp.net,c# Mumbai IT Software - Mainframe BPO/ITES/CRM/Transcription SystemPANJOB000000000001 pankaj Sr. Devp asp.net,c# New Delhi IT Software - Mainframe BPO/ITES/CRM/Transcription ComputersPANJOB000000000001 pankaj Sr. Devp asp.net,c# Mumbai IT Software - Mainframe BPO/ITES/CRM/Transcription ComputersPANJOB000000000001 pankaj Sr. Devp asp.net,c# New Delhi IT Software - Middleware BPO/ITES/CRM/Transcription SystemPANJOB000000000001 pankaj Sr. Devp asp.net,c# Mumbai IT Software - Middleware BPO/ITES/CRM/Transcription SystemPANJOB000000000001 pankaj Sr. Devp asp.net,c# New Delhi IT Software - Middleware BPO/ITES/CRM/Transcription ComputersPANJOB000000000001 pankaj Sr. Devp asp.net,c# Mumbai IT Software - Middleware BPO/ITES/CRM/Transcription ComputersPANJOB000000000001 pankaj Sr. Devp asp.net,c# New Delhi Agent Education/Teaching/Training SystemPANJOB000000000001 pankaj Sr. Devp asp.net,c# Mumbai Agent Education/Teaching/Training SystemPANJOB000000000001 pankaj Sr. Devp asp.net,c# New Delhi Agent Education/Teaching/Training ComputersPANJOB000000000001 pankaj Sr. Devp asp.net,c# Mumbai Agent Education/Teaching/Training ComputersPANJOB000000000001 pankaj Sr. Devp asp.net,c# New Delhi Banking/Insurance Education/Teaching/Training SystemPANJOB000000000001 pankaj Sr. Devp asp.net,c# Mumbai Banking/Insurance Education/Teaching/Training SystemPANJOB000000000001 pankaj Sr. Devp asp.net,c# New Delhi Banking/Insurance Education/Teaching/Training ComputersPANJOB000000000001 pankaj Sr. Devp asp.net,c# Mumbai Banking/Insurance Education/Teaching/Training ComputersPANJOB000000000001 pankaj Sr. Devp asp.net,c# New Delhi IT Software - Client Server Education/Teaching/Training SystemPANJOB000000000001 pankaj Sr. Devp asp.net,c# Mumbai IT Software - Client Server Education/Teaching/Training SystemPANJOB000000000001 pankaj Sr. Devp asp.net,c# New Delhi IT Software - Client Server Education/Teaching/Training ComputersPANJOB000000000001 pankaj Sr. Devp asp.net,c# Mumbai IT Software - Client Server Education/Teaching/Training ComputersPANJOB000000000001 pankaj Sr. Devp asp.net,c# New Delhi IT Software - Mainframe Education/Teaching/Training SystemPANJOB000000000001 pankaj Sr. Devp asp.net,c# Mumbai IT Software - Mainframe Education/Teaching/Training SystemPANJOB000000000001 pankaj Sr. Devp asp.net,c# New Delhi IT Software - Mainframe Education/Teaching/Training ComputersPANJOB000000000001 pankaj Sr. Devp asp.net,c# Mumbai IT Software - Mainframe Education/Teaching/Training ComputersPANJOB000000000001 pankaj Sr. Devp asp.net,c# New Delhi IT Software - Middleware Education/Teaching/Training SystemPANJOB000000000001 pankaj Sr. Devp asp.net,c# Mumbai IT Software - Middleware Education/Teaching/Training SystemPANJOB000000000001 pankaj Sr. Devp asp.net,c# New Delhi IT Software - Middleware Education/Teaching/Training ComputersPANJOB000000000001 pankaj Sr. Devp asp.net,c# Mumbai IT Software - Middleware Education/Teaching/Training ComputersPANJOB000000000002 pankaj Sr.Eng java New Delhi Agent Accounting/Taxation/Finance MarketingPANJOB000000000002 pankaj Sr.Eng java Mumbai Agent Accounting/Taxation/Finance MarketingPANJOB000000000002 pankaj Sr.Eng java New Delhi Architecture / Interior Design Accounting/Taxation/Finance MarketingPANJOB000000000002 pankaj Sr.Eng java Mumbai Architecture / Interior Design Accounting/Taxation/Finance MarketingPANJOB000000000002 pankaj Sr.Eng java New Delhi Agent Advertising/PR/MR/Events MarketingPANJOB000000000002 pankaj Sr.Eng java Mumbai Agent Advertising/PR/MR/Events MarketingPANJOB000000000002 pankaj Sr.Eng java New Delhi Architecture / Interior Design Advertising/PR/MR/Events MarketingPANJOB000000000002 pankaj Sr.Eng java Mumbai Architecture / Interior Design Advertising/PR/MR/Events MarketingI have to find the PANJOB000000000001:- in single row with all detailPANJOB000000000002:- in single row with all detail suggest if any thing can solvedPlease Helppankaj |
 |
|
|
pkuchaliya
Starting Member
49 Posts |
Posted - 2008-07-10 : 03:58:10
|
| hi, as u suggest i have write the query:-select nkjob.job_id,nkjob.employer_profile_id,nkjob.designation,nkjob.key_skill,ncity.city_name,nfarea.functional_type ,nkinds.industry_type,nspcl.specialization_typefrom nk_employer_post_job_ nkjobjoin nk_city_ ncity on nkjob.job_location like '%'+ncity.city_id+'%'join nk_fuctional_area_ nfarea on nkjob.functional_area like '%'+nfarea.functional_id+'%'join nk_industry_type_ nkinds on nkjob.type_of_industry like '%'+nkinds.industry_id+'%'join nk_specialization_ nspcl on nkjob. area_of_specialization like '%'+nspcl.specialization_id+'%'and i got the output like this :-PANJOB000000000001 pankaj Sr.Devp asp.net,c# New Delhi Agent Accounting/Taxation/Finance SystemPANJOB000000000001 pankaj Sr.Devp asp.net,c# Mumbai Agent Accounting/Taxation/Finance SystemPANJOB000000000001 pankaj Sr.Devp asp.net,c# New Delhi Agent Accounting/Taxation/Finance ComputersPANJOB000000000001 pankaj Sr.Devp asp.net,c# Mumbai Agent Accounting/Taxation/Finance ComputersPANJOB000000000001 pankaj Sr.Devp asp.net,c# New Delhi Banking/Insurance Accounting/Taxation/Finance SystemPANJOB000000000001 pankaj Sr.Devp asp.net,c# Mumbai Banking/Insurance Accounting/Taxation/Finance SystemPANJOB000000000001 pankaj Sr.Devp asp.net,c# New Delhi Banking/Insurance Accounting/Taxation/Finance ComputersPANJOB000000000001 pankaj Sr.Devp asp.net,c# Mumbai Banking/Insurance Accounting/Taxation/Finance ComputersPANJOB000000000001 pankaj Sr.Devp asp.net,c# New Delhi IT Software - Client Server Accounting/Taxation/Finance SystemPANJOB000000000001 pankaj Sr.Devp asp.net,c# Mumbai IT Software - Client Server Accounting/Taxation/Finance SystemPANJOB000000000001 pankaj Sr.Devp asp.net,c# New Delhi IT Software - Client Server Accounting/Taxation/Finance ComputersPANJOB000000000001 pankaj Sr.Devp asp.net,c# Mumbai IT Software - Client Server Accounting/Taxation/Finance ComputersPANJOB000000000001 pankaj Sr.Devp asp.net,c# New Delhi IT Software - Mainframe Accounting/Taxation/Finance SystemPANJOB000000000001 pankaj Sr.Devp asp.net,c# Mumbai IT Software - Mainframe Accounting/Taxation/Finance SystemPANJOB000000000001 pankaj Sr.Devp asp.net,c# New Delhi IT Software - Mainframe Accounting/Taxation/Finance ComputersPANJOB000000000001 pankaj Sr.Devp asp.net,c# Mumbai IT Software - Mainframe Accounting/Taxation/Finance ComputersPANJOB000000000001 pankaj Sr.Devp asp.net,c# New Delhi IT Software - Middleware Accounting/Taxation/Finance SystemPANJOB000000000001 pankaj Sr.Devp asp.net,c# Mumbai IT Software - Middleware Accounting/Taxation/Finance SystemPANJOB000000000001 pankaj Sr.Devp asp.net,c# New Delhi IT Software - Middleware Accounting/Taxation/Finance ComputersPANJOB000000000001 pankaj Sr.Devp asp.net,c# Mumbai IT Software - Middleware Accounting/Taxation/Finance ComputersPANJOB000000000001 pankaj Sr.Devp asp.net,c# New Delhi Agent BPO/ITES/CRM/Transcription SystemPANJOB000000000001 pankaj Sr.Devp asp.net,c# Mumbai Agent BPO/ITES/CRM/Transcription SystemPANJOB000000000001 pankaj Sr.Devp asp.net,c# New Delhi Agent BPO/ITES/CRM/Transcription ComputersPANJOB000000000001 pankaj Sr.Devp asp.net,c# Mumbai Agent BPO/ITES/CRM/Transcription ComputersPANJOB000000000001 pankaj Sr.Devp asp.net,c# New Delhi Banking/Insurance BPO/ITES/CRM/Transcription SystemPANJOB000000000001 pankaj Sr.Devp asp.net,c# Mumbai Banking/Insurance BPO/ITES/CRM/Transcription SystemPANJOB000000000001 pankaj Sr.Devp asp.net,c# New Delhi Banking/Insurance BPO/ITES/CRM/Transcription ComputersPANJOB000000000001 pankaj Sr.Devp asp.net,c# Mumbai Banking/Insurance BPO/ITES/CRM/Transcription ComputersPANJOB000000000001 pankaj Sr.Devp asp.net,c# New Delhi IT Software - Client Server BPO/ITES/CRM/Transcription SystemPANJOB000000000001 pankaj Sr.Devp asp.net,c# Mumbai IT Software - Client Server BPO/ITES/CRM/Transcription SystemPANJOB000000000001 pankaj Sr.Devp asp.net,c# New Delhi IT Software - Client Server BPO/ITES/CRM/Transcription ComputersPANJOB000000000001 pankaj Sr.Devp asp.net,c# Mumbai IT Software - Client Server BPO/ITES/CRM/Transcription ComputersPANJOB000000000001 pankaj Sr.Devp asp.net,c# New Delhi IT Software - Mainframe BPO/ITES/CRM/Transcription SystemPANJOB000000000001 pankaj Sr.Devp asp.net,c# Mumbai IT Software - Mainframe BPO/ITES/CRM/Transcription SystemPANJOB000000000001 pankaj Sr.Devp asp.net,c# New Delhi IT Software - Mainframe BPO/ITES/CRM/Transcription ComputersPANJOB000000000001 pankaj Sr.Devp asp.net,c# Mumbai IT Software - Mainframe BPO/ITES/CRM/Transcription ComputersPANJOB000000000001 pankaj Sr.Devp asp.net,c# New Delhi IT Software - Middleware BPO/ITES/CRM/Transcription SystemPANJOB000000000001 pankaj Sr.Devp asp.net,c# Mumbai IT Software - Middleware BPO/ITES/CRM/Transcription SystemPANJOB000000000001 pankaj Sr. Devp asp.net,c# New Delhi IT Software - Middleware BPO/ITES/CRM/Transcription ComputersPANJOB000000000001 pankaj Sr. Devp asp.net,c# Mumbai IT Software - Middleware BPO/ITES/CRM/Transcription ComputersPANJOB000000000001 pankaj Sr. Devp asp.net,c# New Delhi Agent Education/Teaching/Training SystemPANJOB000000000001 pankaj Sr. Devp asp.net,c# Mumbai Agent Education/Teaching/Training SystemPANJOB000000000001 pankaj Sr. Devp asp.net,c# New Delhi Agent Education/Teaching/Training ComputersPANJOB000000000001 pankaj Sr. Devp asp.net,c# Mumbai Agent Education/Teaching/Training ComputersPANJOB000000000001 pankaj Sr. Devp asp.net,c# New Delhi Banking/Insurance Education/Teaching/Training SystemPANJOB000000000001 pankaj Sr. Devp asp.net,c# Mumbai Banking/Insurance Education/Teaching/Training SystemPANJOB000000000001 pankaj Sr. Devp asp.net,c# New Delhi Banking/Insurance Education/Teaching/Training ComputersPANJOB000000000001 pankaj Sr. Devp asp.net,c# Mumbai Banking/Insurance Education/Teaching/Training ComputersPANJOB000000000001 pankaj Sr. Devp asp.net,c# New Delhi IT Software - Client Server Education/Teaching/Training SystemPANJOB000000000001 pankaj Sr. Devp asp.net,c# Mumbai IT Software - Client Server Education/Teaching/Training SystemPANJOB000000000001 pankaj Sr. Devp asp.net,c# New Delhi IT Software - Client Server Education/Teaching/Training ComputersPANJOB000000000001 pankaj Sr. Devp asp.net,c# Mumbai IT Software - Client Server Education/Teaching/Training ComputersPANJOB000000000001 pankaj Sr. Devp asp.net,c# New Delhi IT Software - Mainframe Education/Teaching/Training SystemPANJOB000000000001 pankaj Sr. Devp asp.net,c# Mumbai IT Software - Mainframe Education/Teaching/Training SystemPANJOB000000000001 pankaj Sr. Devp asp.net,c# New Delhi IT Software - Mainframe Education/Teaching/Training ComputersPANJOB000000000001 pankaj Sr. Devp asp.net,c# Mumbai IT Software - Mainframe Education/Teaching/Training ComputersPANJOB000000000001 pankaj Sr. Devp asp.net,c# New Delhi IT Software - Middleware Education/Teaching/Training SystemPANJOB000000000001 pankaj Sr. Devp asp.net,c# Mumbai IT Software - Middleware Education/Teaching/Training SystemPANJOB000000000001 pankaj Sr. Devp asp.net,c# New Delhi IT Software - Middleware Education/Teaching/Training ComputersPANJOB000000000001 pankaj Sr. Devp asp.net,c# Mumbai IT Software - Middleware Education/Teaching/Training ComputersPANJOB000000000002 pankaj Sr.Eng java New Delhi Agent Accounting/Taxation/Finance MarketingPANJOB000000000002 pankaj Sr.Eng java Mumbai Agent Accounting/Taxation/Finance MarketingPANJOB000000000002 pankaj Sr.Eng java New Delhi Architecture / Interior Design Accounting/Taxation/Finance MarketingPANJOB000000000002 pankaj Sr.Eng java Mumbai Architecture / Interior Design Accounting/Taxation/Finance MarketingPANJOB000000000002 pankaj Sr.Eng java New Delhi Agent Advertising/PR/MR/Events MarketingPANJOB000000000002 pankaj Sr.Eng java Mumbai Agent Advertising/PR/MR/Events MarketingPANJOB000000000002 pankaj Sr.Eng java New Delhi Architecture / Interior Design Advertising/PR/MR/Events MarketingPANJOB000000000002 pankaj Sr.Eng java Mumbai Architecture / Interior Design Advertising/PR/MR/Events MarketingI have to find thePANJOB000000000001:- in single row with all detailPANJOB000000000002:- in single row with all detailsuggest if any thing can solvedPlease Helppankajpankaj |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
|
|
|
|
|
|
|