SunQuest
 
           Visual Basic Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
 
User Name:
Password:
Remember me
Go Back   ASP Free ForumsProgrammingVisual Basic Programming

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 ASP Free Forums Sponsor:
Generate data entry and reporting .NET Web apps in minutes, straight from your database. Read our FREE whitepaper “Build Web 2.0 Applications Without Hand-Coding” Download now!
  #1  
Old August 4th, 2004, 01:35 PM
Kristin Kristin is offline
Contributing User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Jul 2004
Posts: 56 Kristin User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 5
clean up on result set?!?!?!

Does anyone know how to get rid of commas and spaces in the result set from my query??

Here is my SQL query:

SELECT records.result, company.company,
records.firstn + ' ' + records.lastn AS DONOR, records.donorid,
records.collecteddate, records.reason, records.lab,
records.speciminid,
records.amphetamine + ' ' + records.butalbital + ' ' + records.cocaine
+ ' ' + records.codeine + ' ' + records.heroin + ' ' + records.marijuana
+ ' ' + records.methadone + ' ' + records.methamphetamine + ' ' +
records.morphine + ' ' + records.phencyclidine + ' ' + records.propoxyphene
+ ' ' + records.otherdrug AS DRUGS, records.status,
records.reportcontact, records.reportdate, records.verifieddate,
records.signature, records.dot, records.nonregulated,
records.reportsentdate, records.form, records.recondate,
records.reconlab
FROM records INNER JOIN
company ON records.mrocomid = company.mrocomid
WHERE (records.recordnum = ?)

Obviously, "DRUGS" is the result set I am talking about....

But I need it to LOOK nice, and right now it comes out something like this....

" Methamphetamine Phencyclidine"

Need it to look like this:

Methamphetamine, Phencyclidine

or

Methamphetamine
Phencyclidine


Any ideas anyone???

Kristin

Reply With Quote
  #2  
Old August 5th, 2004, 09:15 AM
shinu shinu is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Jul 2004
Posts: 27 shinu User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 3 h 5 m 40 sec
Reputation Power: 0
Question hmm?

why u use those quotes in your querry ? what type of database is this ? why it wont work without those qoutes ?

shinu

Reply With Quote
  #3  
Old August 5th, 2004, 10:58 AM
Kristin Kristin is offline
Contributing User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Jul 2004
Posts: 56 Kristin User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 5
It is an SQL Server 2000 database. It is the rule for concantenating....the ' ' puts a space in between each of the results.....

otherwise it looks like this:

MethadoneMethamphetamineOpiates

see what I mean? How can I work around this, if I put ',' then my results look like this...

,,,,,Methadone,,Methamphetamine,,,,Opiates

ugh.

Reply With Quote
  #4  
Old August 10th, 2004, 05:02 AM
Mythomep Mythomep is offline
Contributing User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Aug 2004
Location: Zaandam, The Netherlands
Posts: 70 Mythomep User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 11 m 37 sec
Reputation Power: 4
Send a message via MSN to Mythomep
Hi again,

To solve your problem, use this query:

SELECT records.result, company.company,
records.firstn + ' ' + records.lastn AS DONOR, records.donorid,
records.collecteddate, records.reason, records.lab,
records.speciminid,
CASE WHEN records.amphetamine IS NULL THEN '' ELSE records.amphetamine + ', ' END +
CASE WHEN records.butalbital IS NULL THEN '' ELSE records.butalbital + ', ' END +
CASE WHEN records.cocaine IS NULL THEN '' ELSE Records.cacaine + ', ' END +
CASE WHEN records.codeine IS NULL THEN '' ELSE records.codeine + ', ' END +
CASE WHEN records.heroin IS NULL THEN '' ELSE records.heroin + ', ' END +
CASE WHEN records.marijuana IS NULL THEN '' ELSE records.marijuana + ', ' END +
CASE WHEN records.methadone IS NULL THEN '' ELSE records.methadone + ', ' END + CASE WHEN records.methamphetamine IS NULL THEN '' ELSE records.methamphetamine + ', ' END +
CASE WHEN records.morphine IS NULL THEN '' ELSE records.morphine + ', ' END +
CASE WHEN records.phencyclidine IS NULL THEN '' ELSE records.phencyclidine + ', ' END +
CASE WHEN records.propoxyphene IS NULL THEN '' ELSE records.propoxyphene + ', ' END +
CASE WHEN records.otherdrug IS NULL THEN '' ELSE records.otherdrug END AS DRUGS, records.status,
records.reportcontact, records.reportdate, records.verifieddate,
records.signature, records.dot, records.nonregulated,
records.reportsentdate, records.form, records.recondate,
records.reconlab
FROM records INNER JOIN
company ON records.mrocomid = company.mrocomid
WHERE (records.recordnum = ?)


This will give the output you want, if there are null values in the drug fields. If there are values there (spaces) then use another expression to test (instead of null values). Easy as pie. Any questions, feel free to ask.

Grtz.©

M.

Reply With Quote
Reply

Viewing: ASP Free ForumsProgrammingVisual Basic Programming > clean up on result set?!?!?!


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


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





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