User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the MS SQL section within the Web Development category of DaniWeb, a massive community of 391,962 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 4,037 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our MS SQL advertiser:
Views: 536 | Replies: 0
Reply
Join Date: Mar 2007
Location: South Africa
Posts: 14
Reputation: vuyiswamb is an unknown quantity at this point 
Rep Power: 2
Solved Threads: 0
vuyiswamb's Avatar
vuyiswamb vuyiswamb is offline Offline
Newbie Poster

Help with this Complecated Query

  #1  
Feb 1st, 2008
hi All

i realy need your Help. i have a Table named Property, this Table has a Field named "Lis_key" and Attrib_code and "Func_key", my Table can look like this


Lis_key ===========Attrib_code=========================  Func_key======
=====================================================================
01424545                       1212033993                  PV000000
01424545                       Null                        GEOSS001
01424545                       Null                        GEOSS002
01424545                       Null                        GEOSS003

Figuire:1

Now from the Above table, i call records that have Func_key "Parents" and Records that has Func_key "Children". and in my table there are many Parents that have no Children. Am interested in those that have Children. As you can see the Attrib_code of Children is Null, i have this query that Find the Parents that has Children. and its like this

select p1.Attrib_code,p1.Lis_key
from sde.property_Backup p1
where p1.func_key = 'PV000000'
and exists (select 1
		from sde.property_Backup p2
		where p2.lis_key = p1.lis_key
		and substring(p2.func_key,1,5)='GEOSS' And 
		P1.aCTIVE =1)

Lis_key ======Attrib_code============Func_key======
===========================================
01424545        1212033993         PV000000
01424545        1215035993         PV000000
01424545        3599345445         PV000000
01424545        5035934544         PV000000
Figuire:2



and now as you above, table this Parents have Children with a Fun_key that is like "GEOSS", and they are null. i want to Copy a Attrib_code of a Parent to a Child as long as the Lis_key as the same. and the Final results should be like this

Lis_key ======Attrib_code=========Func_key======
============================================
01424545        1212033993         PV000000
01424545        1212033993         GEOSS001
01424545        1212033993         GEOSS002
01424545        1212033993         GEOSS003
No more Nulls for Attrbi_code for GEOSS, So i need an update Statement for the Children.

Thanks

Please Help
Attached Images
File Type: gif Parents_that_have_Children(Figure1).GIF (5.4 KB, 3 views)
File Type: gif Parent_and_Children(Figuire2).GIF (4.0 KB, 3 views)
AddThis Social Bookmark Button
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

DaniWeb MS SQL Marketplace
Thread Tools Display Modes

Other Threads in the MS SQL Forum

All times are GMT -4. The time now is 9:10 am.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC