Help with SQL Query

  • jordonshaw
  • Student
  • Student
  • User avatar
  • Posts: 96
  • Loc: Tennessee

Post 3+ Months Ago

I'm having a dumb moment right now, so I was wondering if y'all could help. I have this query:

Code: [ Select ]
SELECT crs_name, crs_author, sch_start, sch_end, intro, recorded, edit_av, time,
sd_transc, md_bounced FROM SNP_media
INNER JOIN SNP_crsunits
ON SNP_media.crsunit_id =
SNP_crsunits.crsunit_id
INNER JOIN SNP_crs
ON SNP_crsunits.crs_id =
SNP_crs.crs_id
WHERE intro = '1' OR recorded = '1'
OR edit_av = '1' OR sd_transc = '1'
OR md_bounced = '1'
  1. SELECT crs_name, crs_author, sch_start, sch_end, intro, recorded, edit_av, time,
  2. sd_transc, md_bounced FROM SNP_media
  3. INNER JOIN SNP_crsunits
  4. ON SNP_media.crsunit_id =
  5. SNP_crsunits.crsunit_id
  6. INNER JOIN SNP_crs
  7. ON SNP_crsunits.crs_id =
  8. SNP_crs.crs_id
  9. WHERE intro = '1' OR recorded = '1'
  10. OR edit_av = '1' OR sd_transc = '1'
  11. OR md_bounced = '1'


This gives me what I want; however, to take this a step further, if intro, recorded, edit_av, sd_transc, and md_bounced ALL = '1', I don't want them to show up in my results. So, I want it to show up if one of the fields is set to 1, but if all of them are set to 1, don't show up.

Thanks,
Jordon
  • Anonymous
  • Bot
  • No Avatar
  • Posts: ?
  • Loc: Ozzuland
  • Status: Online

Post 3+ Months Ago

  • jordonshaw
  • Student
  • Student
  • User avatar
  • Posts: 96
  • Loc: Tennessee

Post 3+ Months Ago

Nevermind, I figured it out:
Code: [ Select ]
SELECT SNP_crs.crs_id, crs_name, crs_author, sch_start, sch_end, intro, recorded, edit_av, time,
sd_transc, md_bounced FROM SNP_media
    INNER JOIN SNP_crsunits
    ON SNP_media.crsunit_id =
    SNP_crsunits.crsunit_id
    INNER JOIN SNP_crs
    ON SNP_crsunits.crs_id =
    SNP_crs.crs_id
        WHERE (intro = '1' OR recorded = '1'
        OR edit_av = '1' OR sd_transc = '1'
        OR md_bounced = '1') AND (intro = '0' OR recorded = '0'
        OR edit_av = '0' OR sd_transc = '0'
        OR md_bounced = '0')
  1. SELECT SNP_crs.crs_id, crs_name, crs_author, sch_start, sch_end, intro, recorded, edit_av, time,
  2. sd_transc, md_bounced FROM SNP_media
  3.     INNER JOIN SNP_crsunits
  4.     ON SNP_media.crsunit_id =
  5.     SNP_crsunits.crsunit_id
  6.     INNER JOIN SNP_crs
  7.     ON SNP_crsunits.crs_id =
  8.     SNP_crs.crs_id
  9.         WHERE (intro = '1' OR recorded = '1'
  10.         OR edit_av = '1' OR sd_transc = '1'
  11.         OR md_bounced = '1') AND (intro = '0' OR recorded = '0'
  12.         OR edit_av = '0' OR sd_transc = '0'
  13.         OR md_bounced = '0')
  • Tannu4u
  • Proficient
  • Proficient
  • User avatar
  • Posts: 480
  • Loc: India

Post 3+ Months Ago

Gr8

Post Information

  • Total Posts in this topic: 3 posts
  • Users browsing this forum: No registered users and 150 guests
  • You cannot post new topics in this forum
  • You cannot reply to topics in this forum
  • You cannot edit your posts in this forum
  • You cannot delete your posts in this forum
  • You cannot post attachments in this forum
 
 

© 1998-2014. Ozzu® is a registered trademark of Unmelted, LLC.