MS SQL Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsDatabasesMS SQL Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
Save your reputation with your customers. Learn how you can have embedding success with Advantage Database Server (ADS).
  #1  
Old September 15th, 2003, 06:45 PM
eman eman is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Sep 2003
Location: Minnesota
Posts: 2 eman User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
SQL statement with 2 parameters

I'm making a query for a database and want to have 2 having parameters. this first one works but can't get the second one to.

SELECT Alum.LastName, Alum.FirstName, Alum.Street, Alum.City, Alum.State, Alum.Zipcode, Alum.Country, Alum.Phone, Alum.Email, Alum.Employer, Alum.Title, Alum.WhenGraduated, Alum.DateUpdated, Alum.InitiateNumber, Alum.CompName
FROM Alum
GROUP BY Alum.LastName, Alum.FirstName, Alum.Street, Alum.City, Alum.State, Alum.Zipcode, Alum.Country, Alum.Phone, Alum.Email, Alum.Employer, Alum.Title, Alum.WhenGraduated, Alum.DateUpdated, Alum.InitiateNumber, Alum.CompName
HAVING (((Alum.InitiateNumber)='::inum::'));

I would like to include Alum.FirstName='::fname::' in the having parameter but it keeps giving me an error. What I'm doing is having the two parameters query a database table and where the 2 equal what is entered, return the data from the record.

Any suggestions??!!
Thank you.

Reply With Quote
  #2  
Old September 29th, 2003, 11:26 AM
don_sparko's Avatar
don_sparko don_sparko is offline
Digitally Challenged
Dev Shed Newbie (0 - 499 posts)
 
Join Date: May 2003
Posts: 280 don_sparko User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 54 m 14 sec
Reputation Power: 6
instead of using HAVING you should be using WHERE because you aren't using a group by clause. so it should look something like this
Code:
SELECT Alum.LastName, Alum.FirstName, Alum.Street, Alum.City, Alum.State, Alum.Zipcode, Alum.Country, Alum.Phone, Alum.Email, Alum.Employer, Alum.Title, Alum.WhenGraduated, Alum.DateUpdated, Alum.InitiateNumber, Alum.CompName 
FROM Alum 
GROUP BY Alum.LastName, Alum.FirstName, Alum.Street, Alum.City, Alum.State, Alum.Zipcode, Alum.Country, Alum.Phone, Alum.Email, Alum.Employer, Alum.Title, Alum.WhenGraduated, Alum.DateUpdated, Alum.InitiateNumber, Alum.CompName 
WHERE Alum.InitiateNumber = 1;

the '1' is just the example number i used. if you want it related to a specific number you'll have to tell me what language you are using to display the data. hope that helps
__________________
My brain cells are like a storm trooper's armor: useless

Reply With Quote
  #3  
Old September 29th, 2003, 05:38 PM
eman eman is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Sep 2003
Location: Minnesota
Posts: 2 eman User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Thank you, that makes more sense than the way I had it!!

Reply With Quote
  #4  
Old September 29th, 2003, 08:44 PM
r937's Avatar
r937 r937 is offline
SQL Consultant
Dev Shed God 24th Plane (16500 - 16999 posts)
 
Join Date: Feb 2003
Location: Toronto Canada
Posts: 16,696 r937 User rank is Lieutenant General (80000 - 90000 Reputation Level)r937 User rank is Lieutenant General (80000 - 90000 Reputation Level)r937 User rank is Lieutenant General (80000 - 90000 Reputation Level)r937 User rank is Lieutenant General (80000 - 90000 Reputation Level)r937 User rank is Lieutenant General (80000 - 90000 Reputation Level)r937 User rank is Lieutenant General (80000 - 90000 Reputation Level)r937 User rank is Lieutenant General (80000 - 90000 Reputation Level)r937 User rank is Lieutenant General (80000 - 90000 Reputation Level)r937 User rank is Lieutenant General (80000 - 90000 Reputation Level)r937 User rank is Lieutenant General (80000 - 90000 Reputation Level)r937 User rank is Lieutenant General (80000 - 90000 Reputation Level)r937 User rank is Lieutenant General (80000 - 90000 Reputation Level)r937 User rank is Lieutenant General (80000 - 90000 Reputation Level)r937 User rank is Lieutenant General (80000 - 90000 Reputation Level)r937 User rank is Lieutenant General (80000 - 90000 Reputation Level) 
Time spent in forums: 1 Month 3 Weeks 2 Days 15 h 38 m 17 sec
Reputation Power: 848
except that you cannot put WHERE after GROUP BY!!

furthermore, if you aren't going to use any aggregate functions, then you might as well drop the GROUP BY and use DISTINCT instead

rudy
http://r937.com/

Reply With Quote
Reply

Viewing: Dev Shed ForumsDatabasesMS SQL Development > SQL statement with 2 parameters


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

 Free IT White Papers!
 
Accelerating Trading Partner Performance
One in five. That's how many partner transactions have at least one error. That is an amazing statistic, particularly given the extraordinary leaps in innovation across the global supply chain during the past two decades. Download this white paper to learn more.

 
Competing on Analytics
This Tech Analysis is designed to help identify characteristics shared by analytics competitors, and includes information about 32 organizations that have made a commitment to quantitative, fact-based analysis.

 
Cost Effective Scaling with Virtualization and Coyote Point Systems
An overview of the industry trend toward virtualization, how server consolidation has increased the importance of application uptime and the steps being taken to integrate load balancing technology with virtualized servers.

 
Five Checkpoints to Implementing IP Telephony
Implementation planning for IP PBX software and IP telephony has become vital as businesses replace discontinued legacy PBX phone systems. This informative whitepaper outlines five "checkpoints" for any implementation plan that will help make IP communications a successful proposition.

 
Hosted Email Security: Staying Ahead of New Threats
In the last two years, email has become a fierce battleground between the nefarious forces of spam and malware, and the heroes of messaging protection. The spam volumes increased alarmingly every month, bringing clever new forms of phishing and virus propagation attacks.

 

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 6 hosted by Hostway