Current location: Hot Scripts Forums » Other Discussions » Database » INSERT INTO with Joins help


INSERT INTO with Joins help

Reply
  #1 (permalink)  
Old 05-15-08, 06:09 AM
malycom malycom is offline
New Member
 
Join Date: May 2008
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
INSERT INTO with Joins help

Hi

Sorry if this is going to be long winded but there is no other way I can think of explaining it.

I need to update a table called T_FIXFEE with certain information.

The problem is, this table needs to take certain details from the CLIENTS table and another table called T_ACTIV which is the actual table that holds the value I need to insert.

Here are the tables and the fields from those tables that need to be used. There are many more fields but I think these are the only ones that have any baring.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

CLIENTS
CL_KEY = PK
CL_CATEGORY (I need to only use category CO for the insert)
Other fields but not needed in this example

T_FIXFEE
TFF_CLIENT = PK1 : Links to CL_KEY
TFF_ACTIVITY = PK2 : Links to TA_KEY
Other fields not required

T_ACTIV
TA_KEY = PK

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Basically I need to insert into the table T_FIXFEE a value of DFF which resides in table T_ACTIV, field TA_KEY. I also have to ensure that this only affects clients in this table where clients are Companies, meaning we have to bring CLIENT.CL_CATEGORY value = 'CO' into the equation.

If there is a client in CLIENT.CL_KEY but not in T_FIXFEE.TFF_CLIENT, I also need to make sure that T_FIXFEE insert the client key into T_FIXFEE.TFF_CLIENT

If there is a client in T_FIXFEE that already has the value 'DFF' in TFF_ACTIVITY, I don't need it to add 'DFF'again.

I hope I am explaining myself enough as I am not really sure what needs to be done.

Thanks in advance
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
Reply

Bookmarks


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

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Problem with Auto Dealer Script nuzzle PHP 17 04-14-10 09:34 PM
mysql insert problem zoliky Database 0 07-20-06 03:59 PM
Can not insert data to database trod ASP 5 07-20-05 09:13 AM
MySQL table problem perleo PHP 9 12-16-03 02:16 PM


All times are GMT -5. The time now is 01:09 PM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.