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.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 sql problem urgent

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-bussiness


Please 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,Jobtype
pankaj,delhi,Agent
pankaj,bombay,Agent
pankaj,madras,Agent
pankaj,delhi,account
pankaj,bombay,account
pankaj,madras,account
pankaj,delhi,Bussiness
pankaj,bombay,Bussiness
pankaj,madras,Bussiness

-------------
Charlie
Go to Top of Page

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,Jobtype
pankaj,delhi,Agent
pankaj,bombay,Agent
pankaj,madras,Agent
pankaj,delhi,account
pankaj,bombay,account
pankaj,madras,account
pankaj,delhi,Bussiness
pankaj,bombay,Bussiness
pankaj,madras,Bussiness

-------------
Charlie



pankaj
Go to Top of Page

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]

Go to Top of Page

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_ nkjob
join 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 System
PANJOB000000000001 pankaj Sr. Devp asp.net,c# Mumbai Agent Accounting/Taxation/Finance System
PANJOB000000000001 pankaj Sr. Devp asp.net,c# New Delhi Agent Accounting/Taxation/Finance Computers
PANJOB000000000001 pankaj Sr. Devp asp.net,c# Mumbai Agent Accounting/Taxation/Finance Computers
PANJOB000000000001 pankaj Sr. Devp asp.net,c# New Delhi Banking/Insurance Accounting/Taxation/Finance System
PANJOB000000000001 pankaj Sr. Devp asp.net,c# Mumbai Banking/Insurance Accounting/Taxation/Finance System
PANJOB000000000001 pankaj Sr. Devp asp.net,c# New Delhi Banking/Insurance Accounting/Taxation/Finance Computers
PANJOB000000000001 pankaj Sr. Devp asp.net,c# Mumbai Banking/Insurance Accounting/Taxation/Finance Computers
PANJOB000000000001 pankaj Sr. Devp asp.net,c# New Delhi IT Software - Client Server Accounting/Taxation/Finance System
PANJOB000000000001 pankaj Sr. Devp asp.net,c# Mumbai IT Software - Client Server Accounting/Taxation/Finance System
PANJOB000000000001 pankaj Sr. Devp asp.net,c# New Delhi IT Software - Client Server Accounting/Taxation/Finance Computers
PANJOB000000000001 pankaj Sr. Devp asp.net,c# Mumbai IT Software - Client Server Accounting/Taxation/Finance Computers
PANJOB000000000001 pankaj Sr. Devp asp.net,c# New Delhi IT Software - Mainframe Accounting/Taxation/Finance System
PANJOB000000000001 pankaj Sr. Devp asp.net,c# Mumbai IT Software - Mainframe Accounting/Taxation/Finance System
PANJOB000000000001 pankaj Sr. Devp asp.net,c# New Delhi IT Software - Mainframe Accounting/Taxation/Finance Computers
PANJOB000000000001 pankaj Sr. Devp asp.net,c# Mumbai IT Software - Mainframe Accounting/Taxation/Finance Computers
PANJOB000000000001 pankaj Sr. Devp asp.net,c# New Delhi IT Software - Middleware Accounting/Taxation/Finance System
PANJOB000000000001 pankaj Sr. Devp asp.net,c# Mumbai IT Software - Middleware Accounting/Taxation/Finance System
PANJOB000000000001 pankaj Sr. Devp asp.net,c# New Delhi IT Software - Middleware Accounting/Taxation/Finance Computers
PANJOB000000000001 pankaj Sr. Devp asp.net,c# Mumbai IT Software - Middleware Accounting/Taxation/Finance Computers
PANJOB000000000001 pankaj Sr. Devp asp.net,c# New Delhi Agent BPO/ITES/CRM/Transcription System
PANJOB000000000001 pankaj Sr. Devp asp.net,c# Mumbai Agent BPO/ITES/CRM/Transcription System
PANJOB000000000001 pankaj Sr. Devp asp.net,c# New Delhi Agent BPO/ITES/CRM/Transcription Computers
PANJOB000000000001 pankaj Sr. Devp asp.net,c# Mumbai Agent BPO/ITES/CRM/Transcription Computers
PANJOB000000000001 pankaj Sr. Devp asp.net,c# New Delhi Banking/Insurance BPO/ITES/CRM/Transcription System
PANJOB000000000001 pankaj Sr. Devp asp.net,c# Mumbai Banking/Insurance BPO/ITES/CRM/Transcription System
PANJOB000000000001 pankaj Sr. Devp asp.net,c# New Delhi Banking/Insurance BPO/ITES/CRM/Transcription Computers
PANJOB000000000001 pankaj Sr. Devp asp.net,c# Mumbai Banking/Insurance BPO/ITES/CRM/Transcription Computers
PANJOB000000000001 pankaj Sr. Devp asp.net,c# New Delhi IT Software - Client Server BPO/ITES/CRM/Transcription System
PANJOB000000000001 pankaj Sr. Devp asp.net,c# Mumbai IT Software - Client Server BPO/ITES/CRM/Transcription System
PANJOB000000000001 pankaj Sr. Devp asp.net,c# New Delhi IT Software - Client Server BPO/ITES/CRM/Transcription Computers
PANJOB000000000001 pankaj Sr. Devp asp.net,c# Mumbai IT Software - Client Server BPO/ITES/CRM/Transcription Computers
PANJOB000000000001 pankaj Sr. Devp asp.net,c# New Delhi IT Software - Mainframe BPO/ITES/CRM/Transcription System
PANJOB000000000001 pankaj Sr. Devp asp.net,c# Mumbai IT Software - Mainframe BPO/ITES/CRM/Transcription System
PANJOB000000000001 pankaj Sr. Devp asp.net,c# New Delhi IT Software - Mainframe BPO/ITES/CRM/Transcription Computers
PANJOB000000000001 pankaj Sr. Devp asp.net,c# Mumbai IT Software - Mainframe BPO/ITES/CRM/Transcription Computers
PANJOB000000000001 pankaj Sr. Devp asp.net,c# New Delhi IT Software - Middleware BPO/ITES/CRM/Transcription System
PANJOB000000000001 pankaj Sr. Devp asp.net,c# Mumbai IT Software - Middleware BPO/ITES/CRM/Transcription System
PANJOB000000000001 pankaj Sr. Devp asp.net,c# New Delhi IT Software - Middleware BPO/ITES/CRM/Transcription Computers
PANJOB000000000001 pankaj Sr. Devp asp.net,c# Mumbai IT Software - Middleware BPO/ITES/CRM/Transcription Computers
PANJOB000000000001 pankaj Sr. Devp asp.net,c# New Delhi Agent Education/Teaching/Training System
PANJOB000000000001 pankaj Sr. Devp asp.net,c# Mumbai Agent Education/Teaching/Training System
PANJOB000000000001 pankaj Sr. Devp asp.net,c# New Delhi Agent Education/Teaching/Training Computers
PANJOB000000000001 pankaj Sr. Devp asp.net,c# Mumbai Agent Education/Teaching/Training Computers
PANJOB000000000001 pankaj Sr. Devp asp.net,c# New Delhi Banking/Insurance Education/Teaching/Training System
PANJOB000000000001 pankaj Sr. Devp asp.net,c# Mumbai Banking/Insurance Education/Teaching/Training System
PANJOB000000000001 pankaj Sr. Devp asp.net,c# New Delhi Banking/Insurance Education/Teaching/Training Computers
PANJOB000000000001 pankaj Sr. Devp asp.net,c# Mumbai Banking/Insurance Education/Teaching/Training Computers
PANJOB000000000001 pankaj Sr. Devp asp.net,c# New Delhi IT Software - Client Server Education/Teaching/Training System
PANJOB000000000001 pankaj Sr. Devp asp.net,c# Mumbai IT Software - Client Server Education/Teaching/Training System
PANJOB000000000001 pankaj Sr. Devp asp.net,c# New Delhi IT Software - Client Server Education/Teaching/Training Computers
PANJOB000000000001 pankaj Sr. Devp asp.net,c# Mumbai IT Software - Client Server Education/Teaching/Training Computers
PANJOB000000000001 pankaj Sr. Devp asp.net,c# New Delhi IT Software - Mainframe Education/Teaching/Training System
PANJOB000000000001 pankaj Sr. Devp asp.net,c# Mumbai IT Software - Mainframe Education/Teaching/Training System
PANJOB000000000001 pankaj Sr. Devp asp.net,c# New Delhi IT Software - Mainframe Education/Teaching/Training Computers
PANJOB000000000001 pankaj Sr. Devp asp.net,c# Mumbai IT Software - Mainframe Education/Teaching/Training Computers
PANJOB000000000001 pankaj Sr. Devp asp.net,c# New Delhi IT Software - Middleware Education/Teaching/Training System
PANJOB000000000001 pankaj Sr. Devp asp.net,c# Mumbai IT Software - Middleware Education/Teaching/Training System
PANJOB000000000001 pankaj Sr. Devp asp.net,c# New Delhi IT Software - Middleware Education/Teaching/Training Computers
PANJOB000000000001 pankaj Sr. Devp asp.net,c# Mumbai IT Software - Middleware Education/Teaching/Training Computers
PANJOB000000000002 pankaj Sr.Eng java New Delhi Agent Accounting/Taxation/Finance Marketing
PANJOB000000000002 pankaj Sr.Eng java Mumbai Agent Accounting/Taxation/Finance Marketing
PANJOB000000000002 pankaj Sr.Eng java New Delhi Architecture / Interior Design Accounting/Taxation/Finance Marketing
PANJOB000000000002 pankaj Sr.Eng java Mumbai Architecture / Interior Design Accounting/Taxation/Finance Marketing
PANJOB000000000002 pankaj Sr.Eng java New Delhi Agent Advertising/PR/MR/Events Marketing
PANJOB000000000002 pankaj Sr.Eng java Mumbai Agent Advertising/PR/MR/Events Marketing
PANJOB000000000002 pankaj Sr.Eng java New Delhi Architecture / Interior Design Advertising/PR/MR/Events Marketing
PANJOB000000000002 pankaj Sr.Eng java Mumbai Architecture / Interior Design Advertising/PR/MR/Events Marketing


I have to find the

PANJOB000000000001:- in single row with all detail
PANJOB000000000002:- in single row with all detail
suggest if any thing can solved
Please Help

pankaj
Go to Top of Page

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_type
from nk_employer_post_job_ nkjob
join 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 System
PANJOB000000000001 pankaj Sr.Devp asp.net,c# Mumbai Agent Accounting/Taxation/Finance System
PANJOB000000000001 pankaj Sr.Devp asp.net,c# New Delhi Agent Accounting/Taxation/Finance Computers
PANJOB000000000001 pankaj Sr.Devp asp.net,c# Mumbai Agent Accounting/Taxation/Finance Computers
PANJOB000000000001 pankaj Sr.Devp asp.net,c# New Delhi Banking/Insurance Accounting/Taxation/Finance System
PANJOB000000000001 pankaj Sr.Devp asp.net,c# Mumbai Banking/Insurance Accounting/Taxation/Finance System
PANJOB000000000001 pankaj Sr.Devp asp.net,c# New Delhi Banking/Insurance Accounting/Taxation/Finance Computers
PANJOB000000000001 pankaj Sr.Devp asp.net,c# Mumbai Banking/Insurance Accounting/Taxation/Finance Computers
PANJOB000000000001 pankaj Sr.Devp asp.net,c# New Delhi IT Software - Client Server Accounting/Taxation/Finance System
PANJOB000000000001 pankaj Sr.Devp asp.net,c# Mumbai IT Software - Client Server Accounting/Taxation/Finance System
PANJOB000000000001 pankaj Sr.Devp asp.net,c# New Delhi IT Software - Client Server Accounting/Taxation/Finance Computers
PANJOB000000000001 pankaj Sr.Devp asp.net,c# Mumbai IT Software - Client Server Accounting/Taxation/Finance Computers
PANJOB000000000001 pankaj Sr.Devp asp.net,c# New Delhi IT Software - Mainframe Accounting/Taxation/Finance System
PANJOB000000000001 pankaj Sr.Devp asp.net,c# Mumbai IT Software - Mainframe Accounting/Taxation/Finance System
PANJOB000000000001 pankaj Sr.Devp asp.net,c# New Delhi IT Software - Mainframe Accounting/Taxation/Finance Computers
PANJOB000000000001 pankaj Sr.Devp asp.net,c# Mumbai IT Software - Mainframe Accounting/Taxation/Finance Computers
PANJOB000000000001 pankaj Sr.Devp asp.net,c# New Delhi IT Software - Middleware Accounting/Taxation/Finance System
PANJOB000000000001 pankaj Sr.Devp asp.net,c# Mumbai IT Software - Middleware Accounting/Taxation/Finance System
PANJOB000000000001 pankaj Sr.Devp asp.net,c# New Delhi IT Software - Middleware Accounting/Taxation/Finance Computers
PANJOB000000000001 pankaj Sr.Devp asp.net,c# Mumbai IT Software - Middleware Accounting/Taxation/Finance Computers
PANJOB000000000001 pankaj Sr.Devp asp.net,c# New Delhi Agent BPO/ITES/CRM/Transcription System
PANJOB000000000001 pankaj Sr.Devp asp.net,c# Mumbai Agent BPO/ITES/CRM/Transcription System
PANJOB000000000001 pankaj Sr.Devp asp.net,c# New Delhi Agent BPO/ITES/CRM/Transcription Computers
PANJOB000000000001 pankaj Sr.Devp asp.net,c# Mumbai Agent BPO/ITES/CRM/Transcription Computers
PANJOB000000000001 pankaj Sr.Devp asp.net,c# New Delhi Banking/Insurance BPO/ITES/CRM/Transcription System
PANJOB000000000001 pankaj Sr.Devp asp.net,c# Mumbai Banking/Insurance BPO/ITES/CRM/Transcription System
PANJOB000000000001 pankaj Sr.Devp asp.net,c# New Delhi Banking/Insurance BPO/ITES/CRM/Transcription Computers
PANJOB000000000001 pankaj Sr.Devp asp.net,c# Mumbai Banking/Insurance BPO/ITES/CRM/Transcription Computers
PANJOB000000000001 pankaj Sr.Devp asp.net,c# New Delhi IT Software - Client Server BPO/ITES/CRM/Transcription System
PANJOB000000000001 pankaj Sr.Devp asp.net,c# Mumbai IT Software - Client Server BPO/ITES/CRM/Transcription System
PANJOB000000000001 pankaj Sr.Devp asp.net,c# New Delhi IT Software - Client Server BPO/ITES/CRM/Transcription Computers
PANJOB000000000001 pankaj Sr.Devp asp.net,c# Mumbai IT Software - Client Server BPO/ITES/CRM/Transcription Computers
PANJOB000000000001 pankaj Sr.Devp asp.net,c# New Delhi IT Software - Mainframe BPO/ITES/CRM/Transcription System
PANJOB000000000001 pankaj Sr.Devp asp.net,c# Mumbai IT Software - Mainframe BPO/ITES/CRM/Transcription System
PANJOB000000000001 pankaj Sr.Devp asp.net,c# New Delhi IT Software - Mainframe BPO/ITES/CRM/Transcription Computers
PANJOB000000000001 pankaj Sr.Devp asp.net,c# Mumbai IT Software - Mainframe BPO/ITES/CRM/Transcription Computers
PANJOB000000000001 pankaj Sr.Devp asp.net,c# New Delhi IT Software - Middleware BPO/ITES/CRM/Transcription System
PANJOB000000000001 pankaj Sr.Devp asp.net,c# Mumbai IT Software - Middleware BPO/ITES/CRM/Transcription System
PANJOB000000000001 pankaj Sr. Devp asp.net,c# New Delhi IT Software - Middleware BPO/ITES/CRM/Transcription Computers
PANJOB000000000001 pankaj Sr. Devp asp.net,c# Mumbai IT Software - Middleware BPO/ITES/CRM/Transcription Computers
PANJOB000000000001 pankaj Sr. Devp asp.net,c# New Delhi Agent Education/Teaching/Training System
PANJOB000000000001 pankaj Sr. Devp asp.net,c# Mumbai Agent Education/Teaching/Training System
PANJOB000000000001 pankaj Sr. Devp asp.net,c# New Delhi Agent Education/Teaching/Training Computers
PANJOB000000000001 pankaj Sr. Devp asp.net,c# Mumbai Agent Education/Teaching/Training Computers
PANJOB000000000001 pankaj Sr. Devp asp.net,c# New Delhi Banking/Insurance Education/Teaching/Training System
PANJOB000000000001 pankaj Sr. Devp asp.net,c# Mumbai Banking/Insurance Education/Teaching/Training System
PANJOB000000000001 pankaj Sr. Devp asp.net,c# New Delhi Banking/Insurance Education/Teaching/Training Computers
PANJOB000000000001 pankaj Sr. Devp asp.net,c# Mumbai Banking/Insurance Education/Teaching/Training Computers
PANJOB000000000001 pankaj Sr. Devp asp.net,c# New Delhi IT Software - Client Server Education/Teaching/Training System
PANJOB000000000001 pankaj Sr. Devp asp.net,c# Mumbai IT Software - Client Server Education/Teaching/Training System
PANJOB000000000001 pankaj Sr. Devp asp.net,c# New Delhi IT Software - Client Server Education/Teaching/Training Computers
PANJOB000000000001 pankaj Sr. Devp asp.net,c# Mumbai IT Software - Client Server Education/Teaching/Training Computers
PANJOB000000000001 pankaj Sr. Devp asp.net,c# New Delhi IT Software - Mainframe Education/Teaching/Training System
PANJOB000000000001 pankaj Sr. Devp asp.net,c# Mumbai IT Software - Mainframe Education/Teaching/Training System
PANJOB000000000001 pankaj Sr. Devp asp.net,c# New Delhi IT Software - Mainframe Education/Teaching/Training Computers
PANJOB000000000001 pankaj Sr. Devp asp.net,c# Mumbai IT Software - Mainframe Education/Teaching/Training Computers
PANJOB000000000001 pankaj Sr. Devp asp.net,c# New Delhi IT Software - Middleware Education/Teaching/Training System
PANJOB000000000001 pankaj Sr. Devp asp.net,c# Mumbai IT Software - Middleware Education/Teaching/Training System
PANJOB000000000001 pankaj Sr. Devp asp.net,c# New Delhi IT Software - Middleware Education/Teaching/Training Computers
PANJOB000000000001 pankaj Sr. Devp asp.net,c# Mumbai IT Software - Middleware Education/Teaching/Training Computers
PANJOB000000000002 pankaj Sr.Eng java New Delhi Agent Accounting/Taxation/Finance Marketing
PANJOB000000000002 pankaj Sr.Eng java Mumbai Agent Accounting/Taxation/Finance Marketing
PANJOB000000000002 pankaj Sr.Eng java New Delhi Architecture / Interior Design Accounting/Taxation/Finance Marketing
PANJOB000000000002 pankaj Sr.Eng java Mumbai Architecture / Interior Design Accounting/Taxation/Finance Marketing
PANJOB000000000002 pankaj Sr.Eng java New Delhi Agent Advertising/PR/MR/Events Marketing
PANJOB000000000002 pankaj Sr.Eng java Mumbai Agent Advertising/PR/MR/Events Marketing
PANJOB000000000002 pankaj Sr.Eng java New Delhi Architecture / Interior Design Advertising/PR/MR/Events Marketing
PANJOB000000000002 pankaj Sr.Eng java Mumbai Architecture / Interior Design Advertising/PR/MR/Events Marketing


I have to find the

PANJOB000000000001:- in single row with all detail
PANJOB000000000002:- in single row with all detail
suggest if any thing can solved
Please Help

pankaj


pankaj
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-07-10 : 03:58:55
Answered here:-

http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=106350
Go to Top of Page
   

- Advertisement -