Lively discussions on the graphic arts and publishing — in print or on the web

Go Back   Desktop Publishing Forum > General Discussions > Web Site Building & Maintenance

Thread Tools Display Modes
Prev Previous Post   Next Post Next
Old 03-07-2007, 06:17 PM   #1
CarlSeiler's Avatar
Join Date: Oct 2005
Location: Denton, TX
Posts: 280
Default SQL Help Needed

Need to get my head wrapped around some common SQL techniques. We've got data in three different linked tables.

cust_id cust_name
1 Bill
2 Mary
3 John

custact_id cust_id
11 1
12 1
13 3
14 2

warrant_id custact_id
101 12
102 13

Now, I want to insert a warrant 103 for Mary (customer 2). I can easily do this using:

INSERT INTO warrants (warrant_id, custact_id) VALUES (103, 14);
but this works because I can see that one of the custact_id that's associated with Mary is 14, so I can feed it a correct custact_id, but what if I don't know the custact_id? Since I know Mary is number 2 (from the first table) is there some way to construct the query so that it's something like this pseudo code:

INSERT INTO warrants (warrant_id, custact_id) 
VALUES (103, [SELECT custact_id from custactions WHERE cust_id = 2]);
In other words, I want the query to figure out on its own that it needs to put 14 the second value of the INSERT by looking it up in the custactions table. Does this make sense at all? I think I have the right idea, but not the right syntax. Am I looking for something like:

INSERT INTO warrants (warrant_id, custact_id)
SELECT 103, custact_id FROM custactions WHERE cust_id = 2

(Sorry, I accidentally hit "save" save earlier before I was finished.)

Last edited by CarlSeiler; 03-07-2007 at 07:01 PM. Reason: Couldn't figure out how to delete it.
CarlSeiler is offline   Reply With Quote

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 On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Needed: someone to manage a Simple Machines Forum mksf Web Site Building & Maintenance 13 04-05-2007 06:02 AM
Quark Xpress Tutor Needed Ash Mansukhani Print Design 2 10-24-2006 11:47 AM
Redesign Suggestions Needed BobRoosth Web Design 11 01-09-2006 08:57 AM
Word vs Acrobat guru needed!! ktinkel Print Production & Automation 7 05-13-2005 08:51 AM
RGB-CMYK Tutorial Needed BobRoosth Print Production & Automation 15 02-28-2005 06:44 PM

All times are GMT -8. The time now is 03:00 AM.

Powered by vBulletin® Version 3.8.9
Copyright ©2000 - 2018, vBulletin Solutions, Inc.
Contents copyright 2004–2018 Desktop Publishing Forum and its members.