Results 1 to 4 of 4

Thread: I love SQL. Not.

  1. #1
    A Straw? And Fruit? Bazzlad's Avatar
    Join Date
    Jul 2003
    Location
    The Big Rhesus House Stourbridge
    Posts
    3,072
    Thanks
    90
    Thanked
    78 times in 44 posts

    I love SQL. Not.

    Just a quick query, any SQL gurus may be able to help here.
    When I run this:

    SELECT * FROM tblproblem
    WHERE [reported by] ='karl'
    or [reported by] ='Rich'
    And [Date reported] Between forms!frmreportbuilder!text12.value And forms!frmreportbuilder!text14.value
    And [Repaired] = yes
    AND [external help enlisted] between yes and no
    And [repair date] Between forms!frmreportbuilder!text25.value And forms!frmreportbuilder!text27.value
    AND [In use] between yes and no ;

    Why do the conditions only apply to records from "Rich" and not "Karl"?

    What am I missing?

  2. #2
    Senior Member
    Join Date
    Aug 2005
    Posts
    213
    Thanks
    0
    Thanked
    0 times in 0 posts
    braces around your OR clause?

  3. #3
    www.5lab.co.uk
    Join Date
    Sep 2003
    Posts
    6,406
    Thanks
    1
    Thanked
    0 times in 0 posts
    Quote Originally Posted by Bazzlad
    Just a quick query, any SQL gurus may be able to help here.
    When I run this:

    SELECT * FROM tblproblem
    WHERE [reported by] ='karl'
    or [reported by] ='Rich'
    And [Date reported] Between forms!frmreportbuilder!text12.value And forms!frmreportbuilder!text14.value
    And [Repaired] = yes
    AND [external help enlisted] between yes and no
    And [repair date] Between forms!frmreportbuilder!text25.value And forms!frmreportbuilder!text27.value
    AND [In use] between yes and no ;

    Why do the conditions only apply to records from "Rich" and not "Karl"?

    What am I missing?
    you need
    Code:
    SELECT * FROM tblproblem 
    WHERE  ([reported by] ='karl'
    or  [reported by] ='Rich')
    And [Date reported] Between forms!frmreportbuilder!text12.value And forms!frmreportbuilder!text14.value 
    And [Repaired] = yes
    AND [external help enlisted] between yes and no 
    And [repair date] Between forms!frmreportbuilder!text25.value And forms!frmreportbuilder!text27.value 
    AND [In use] between yes and no ;
    at the moment it is running

    Code:
    SELECT * FROM tblproblem 
    WHERE  [reported by] ='karl'
    or  ([reported by] ='Rich'
    And [Date reported] Between forms!frmreportbuilder!text12.value And forms!frmreportbuilder!text14.value 
    And [Repaired] = yes
    AND [external help enlisted] between yes and no 
    And [repair date] Between forms!frmreportbuilder!text25.value And forms!frmreportbuilder!text27.value 
    AND [In use] between yes and no) ;
    hughlunnon@yahoo.com | I have sigs turned off..

  4. #4
    A Straw? And Fruit? Bazzlad's Avatar
    Join Date
    Jul 2003
    Location
    The Big Rhesus House Stourbridge
    Posts
    3,072
    Thanks
    90
    Thanked
    78 times in 44 posts
    I love you both.


Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Member Database SQL / PHP
    By realm in forum Software
    Replies: 4
    Last Post: 03-01-2006, 06:48 PM
  2. SQL Server 2000
    By Fatboy in forum Software
    Replies: 37
    Last Post: 17-08-2005, 07:05 PM
  3. SQL Server Connection string?
    By Stoo in forum Software
    Replies: 7
    Last Post: 04-05-2005, 05:48 PM
  4. SQL Connection
    By Raz316 in forum Software
    Replies: 2
    Last Post: 11-08-2004, 06:58 PM
  5. Do you believe in a thing called love?
    By TeePee in forum Question Time
    Replies: 8
    Last Post: 18-11-2003, 10:45 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •