iEntry 10th Anniversary Forum Rules Search
WebProWorld
Register FAQ Calendar Mark Forums Read
Database Discussion Forum This is the place to find help resolving those nagging questions you have about implementing and using all kinds of databases. Need help writing a query? Need an opinion on Oracle? Post here!

Share Thread: & Tags

Share Thread:

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 02-09-2009, 05:24 PM
WebProWorld New Member
 
Join Date: Feb 2009
Posts: 3
jazaddict RepRank 0
Default Need a wee bit o' SQL help

Hi.
This works, but it returns duplicates
"INSERT INTO tblTargetAdd ( targetID ) SELECT * FROM Target WHERE (((Target.targetID)=" & Int(Me!lstAddACFT) & "));"



THis eliminates the duplicates, but I can't seem to get it incorporated into the previous query

SELECT target.targetID, Target.Name,Target.RSI FROM Target WHERE (((Target.RSI)="31101")) group by Target.Name,Target.RSI,TargetID;

can one of you whiz-bang SQL-ers help me get the append query to ONLY append 1 copy of each?

I can tell you that neither this

INSERT INTO tblTargetAdd ( targetID ) SELECT * FROM Target WHERE target.targetID, Target.Name,Target.RSI IN (SELECT target.targetID, Target.Name,Target.RSI FROM Target WHERE Target.RSI="31101" group by Target.Name,Target.RSI,TargetID);



nor this




INSERT INTO tblTargetAdd ( targetID ) SELECT * FROM Target WHERE target.targetID IN (SELECT target.targetID, Target.Name,Target.RSI FROM Target WHERE Target.RSI="31101" group by Target.Name,Target.RSI,TargetID);



Work. Thanks










Reply With Quote
  #2 (permalink)  
Old 02-09-2009, 09:29 PM
danlefree's Avatar
WebProWorld Pro
 
Join Date: Jun 2005
Location: Seattle
Posts: 268
danlefree RepRank 4danlefree RepRank 4danlefree RepRank 4danlefree RepRank 4
Default Re: Need a wee bit o' SQL help

Have you tried the LIMIT directive?

Code:
SELECT target.targetID, Target.Name,Target.RSI FROM Target WHERE (((Target.RSI)="31101")) group by Target.Name,Target.RSI,TargetID LIMIT 1;
__________________
Dan LeFree | Product Manager (Linux VPS Hosting) | Owner/Operator (Web development, marketing)
Reply With Quote
  #3 (permalink)  
Old 02-10-2009, 05:22 PM
WebProWorld New Member
 
Join Date: Feb 2009
Posts: 3
jazaddict RepRank 0
Default Re: Need a wee bit o' SQL help

Hi danlefree,
Thanks for takin the time to respond.
I should have mentioned I'm using MS Access in which there is no LIMIT keyword.

However,I got it to work as follows:

INSERT INTO tblTargetAdd
SELECT *
FROM Target
WHERE TargetID in (SELECT targetID FROM Target WHERE RSI="31101");


It only took 2 days of head-scratching to find what turned out to be a SIMPLE solution
Reply With Quote
  #4 (permalink)  
Old 02-11-2009, 12:44 PM
WebProWorld New Member
 
Join Date: Feb 2009
Posts: 3
jazaddict RepRank 0
Default Re: Need a wee bit o' SQL help

Well.....I've apparently lost my mind.
The previous does NOT work as it still gives me dupes.....but "limit" doesn't exist in Access so I'm back to square 1.
Reply With Quote
  #5 (permalink)  
Old 02-11-2009, 04:23 PM
danlefree's Avatar
WebProWorld Pro
 
Join Date: Jun 2005
Location: Seattle
Posts: 268
danlefree RepRank 4danlefree RepRank 4danlefree RepRank 4danlefree RepRank 4
Default Re: Need a wee bit o' SQL help

This might be what you're looking for:

Code:
MYSQL
"SELECT ... WHERE ... LIMIT N"

MS Access
"SELECT TOP N WHERE ..."
__________________
Dan LeFree | Product Manager (Linux VPS Hosting) | Owner/Operator (Web development, marketing)
Reply With Quote
  #6 (permalink)  
Old 02-18-2009, 06:10 PM
danlefree's Avatar
WebProWorld Pro
 
Join Date: Jun 2005
Location: Seattle
Posts: 268
danlefree RepRank 4danlefree RepRank 4danlefree RepRank 4danlefree RepRank 4
Default Re: Need a wee bit o' SQL help

Did the top directive end up working out for you ..?
__________________
Dan LeFree | Product Manager (Linux VPS Hosting) | Owner/Operator (Web development, marketing)
Reply With Quote
Reply

  WebProWorld > Webmaster, IT and Security Discussion > Database Discussion Forum

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
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT -4. The time now is 12:35 AM.



Search Engine Optimization by vBSEO 3.3.0