SitePoint Sponsor

User Tag List

Results 1 to 3 of 3

Thread: sql question

  1. #1
    SitePoint Guru johnjohn2's Avatar
    Join Date
    Apr 2004
    Location
    here
    Posts
    746
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    sql question

    This query works almost 100%. I'm trying to make so that it will include the records WHERE (tbl33.col13 = recordid16) AND ((tbl33.col17 =0) AND/OR (tbl24.col11=1)). The "((tbl33.col17 =0) AND/OR (tbl24.col11=1))" part of it is where it's messed up. I'm not sure how to specify a condition where the query will accept either value.

    This is what I'm trying to use now but it doesn't work.

    SELECT tbl24.col2 as col2b, tbl33.col1, tbl33.col3, tbl33.col4, to_char(tbl33.col4, '999,999,999,999,999.99') as col4formatted, tbl33.col5, tbl33.col6, tbl33.col7, tbl33.col13, tbl33.col14, tbl24.col11 as col11b
    FROM tbl33 INNER JOIN tbl24 ON tbl33.col3 = tbl24.col1
    WHERE (tbl33.col13 = recordid16) AND ((tbl33.col17 =0) OR (tbl24.col11=1))
    ORDER BY tbl24.col2 ASC, tbl33.col7 DESC

  2. #2
    SitePoint Addict matt_12511's Avatar
    Join Date
    Feb 2004
    Location
    Michigan
    Posts
    256
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I just tried this in access and it worked for me.

    I would put the same equation in parentheses on both sides:

    Code:
    WHERE ((tbl33.col13 = recordid16) AND (tbl33.col17 =0)) OR ((tbl24.col11=1) AND (tbl33.col13 = recordid16))
    You need parentheses around each set.

    Should work.

    Matt

  3. #3
    SitePoint Guru johnjohn2's Avatar
    Join Date
    Apr 2004
    Location
    here
    Posts
    746
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks for the help!

    Quote Originally Posted by matt_12511
    I just tried this in access and it worked for me.

    I would put the same equation in parentheses on both sides:

    Code:
    WHERE ((tbl33.col13 = recordid16) AND (tbl33.col17 =0)) OR ((tbl24.col11=1) AND (tbl33.col13 = recordid16))
    You need parentheses around each set.

    Should work.

    Matt


Bookmarks

Posting Permissions

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