Results 1 to 9 of 9
  1. #1
    sshr is offline Novice
    Windows XP Access 2003
    Join Date
    Sep 2011
    Posts
    5

    Query Check

    (select (iif (max([second table].[publishing]) = "True", "Yes", iif (max([first table].[publishing]) = "False", "No", "Error")) from [first table] group by [second table].url where ((([first table].[site url] = [second table].Url))) as haspublish



    I have to put this query inside another query so that the output table is complete...

    Please let me know if there is any mistake...

    Publish has blank, true or false as string

    I have tables as
    Table 1
    url ........
    a
    b

    Table 2
    Site Url Extend Publishing
    a a/b False
    a a/c False
    a a/d False
    b b/e False
    b b/f True
    b b/g False

    Result Query needed:
    Url Publish
    a False
    b True

    Thanks in advance

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,771
    Best way to find out if it has errors is to run it. When it accomplishes what you want, then nest it into the other query.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  3. #3
    sshr is offline Novice
    Windows XP Access 2003
    Join Date
    Sep 2011
    Posts
    5
    Even if i do it seperately, the values are all wrong!!

    I think the max() is all wrong!!! I could not figure what to do next!!!

  4. #4
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,771
    What is [what is]? This should be one of the two table names.

    Not understanding why the first table criteria.

    If the True/False field is a Yes/No datatype, try:
    SELECT [Second Table].[Site URL], Max(Iif(Publishing=True,"Yes","No")) AS MaxOfPublishing
    FROM [Second Table]
    GROUP BY [Second Table].[Site URL];

    It it is a text datatype, try:
    SELECT [Second Table].[Site URL], Max([Second Table].Publishing) AS MaxOfPublishing
    FROM [Second Table]
    GROUP BY [Second Table].[Site URL];
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  5. #5
    sshr is offline Novice
    Windows XP Access 2003
    Join Date
    Sep 2011
    Posts
    5
    I got the code running if i run the code alone... but when I add it as a subquery it says the subquery cannot have more than 1 value!!!

    The code I could run is
    select iif(max([second table].publish)="True", "yes", "No")
    from [first table],[second table]
    where [second table].[site url]=[first table].url
    group by [first table].url

    Actually publish is the text string!

  6. #6
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,771
    You saved the query as an Access object? Then you built another query referencing the saved object? That's how I build nested queries. Build them in sequence and make sure they work then I copy/paste the first query into the second.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  7. #7
    sshr is offline Novice
    Windows XP Access 2003
    Join Date
    Sep 2011
    Posts
    5
    how do I save it as an Access Object??

  8. #8
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,771
    Use the Access query designer or wizard. Save the query. That is an Access object. Other Access objects are tables, forms, reports.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  9. #9
    sshr is offline Novice
    Windows XP Access 2003
    Join Date
    Sep 2011
    Posts
    5
    Thanks June7 for your help!!

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 1
    Last Post: 08-14-2011, 11:31 PM
  2. In query: check criteria with default value
    By hoachen in forum Access
    Replies: 1
    Last Post: 07-12-2011, 10:23 AM
  3. Access Query to Check Timestamp
    By Meh in forum Access
    Replies: 1
    Last Post: 12-21-2010, 07:18 PM
  4. How to Query fields with check boxes?
    By JynxRD in forum Queries
    Replies: 2
    Last Post: 09-10-2010, 08:35 PM
  5. Replies: 0
    Last Post: 07-05-2010, 08:00 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums