Results 1 to 3 of 3
  1. #1
    Blitz is offline Novice
    Windows 7 32bit Access 2002
    Join Date
    Nov 2012
    Posts
    2

    Query from 2 tables

    Hi,

    I am trying to make a query based on 2 tables, but I need help.

    Setup:
    Table1 has a column with dates, and a column with yes/no (boolean)
    Table2 has a column with dates, and several other columns

    I made a one-on-one relationship between the dates from both tables. I cannot put the yes/no field in table2, because I need to import csv-data into table2, which seems to fail when there are more columns in table2 than in the csv-file.

    Now I need a query that holds all the records from table2 that have a matching "no" in table1.

    what is the SQL for that? I expect it will start with "select * from table2 where..."

    I understand what they mean by "relationship" (and the different types of relationships), but I don't see how I can use those relationships in Access. Does SQL give different results for databases with / without defined relationships?



    Should be an easy one for advanced users I guess...

  2. #2
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,530
    Start a new query, select both tables. If no join line appears between the related date fields, click/drag to create one. Select the desired fields from the second table and the yes/no field from the first. Put 0 in the criteria of that field and run the query.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,959
    The date value is unique in each table (only one record for each date, no time component)? Use the Access query designer to build query. Set a link between the two tables in the design window. The result will be like:

    SELECT Table1.*, Table2.* FROM Table1 INNER JOIN Table2 ON Table1.[Datefield]=Table2.[Datefield] WHERE Table1.[Yes/no field] = No;
    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.

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

Similar Threads

  1. Replies: 3
    Last Post: 01-05-2012, 12:04 PM
  2. 1 query 2 tables help?
    By mejia.j88 in forum Queries
    Replies: 4
    Last Post: 11-22-2011, 03:23 PM
  3. Trying this query from 2-Tables
    By djclntn in forum Queries
    Replies: 6
    Last Post: 11-13-2011, 09:25 AM
  4. Query on 3 tables
    By aveit in forum Access
    Replies: 0
    Last Post: 04-26-2011, 12:01 PM
  5. Query -2 tables. Help.
    By zuli007 in forum Queries
    Replies: 1
    Last Post: 04-15-2010, 10:02 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