Re: Help with a multiple table query

From: Hugo Kornelis (hugo_at_pe_NO_rFact.in_SPAM_fo)
Date: 11/04/04

  • Next message: jj: "Creating a Basic SQL Model (tutorial)"
    Date: Thu, 04 Nov 2004 10:08:26 +0100
    
    

    On Wed, 3 Nov 2004 20:00:03 -0800, Dave Lugo wrote:

    >Hi,
    >
    >I need help in constructing a query against my Db I have. The DB I have has
    >122 Tables and 15 columns in each. I have information in a column in one
    >table that I need to query with data in a column on another table. In other
    >words, In Table ad, i have a column called ENTRY_ID that I want to query
    >against data in the column PUBLISH_DATE in table INSERT.
    >
    >This is what I have so far.
    >
    >select a.ad_number,a.entry_date,b.publish_date
    >from ad a, ad_insert b where a.entry_date = '2004-11-03'and b.publish_date =
    >'2004-11-04'
    >
    >I know I have records but the query produces no results so
    >any help on what I am missing would be greatly appreciated.

    Hi Dave,

    The syntax looks okay - if there are matching rows in both tables, they
    should show up. Without knowing your table structure and the data that's
    in your table, it's hard to get more specific than this. If you need more
    specific answers, you'll have to provide more specific information first.
    See www.aspfaq.com/5006.

    Some general remakrs that might or might not apply to your query:
    * The date format 2004-11-03 is ambiguous - do you mean November 3rd or
    March 11th? The only date formats that are completely safe to use are:
    - yyyymmmdd (for date only - remember: no seperators in this format!),
    - yyyy-mm-ddThh:mm:ss (for date plus time - note the capital T),
    - yyyy-mm-ddThh:mm:ss.mmm (idem, but including milliseconds).

    * I assume that the dates are stored using the datetime datatype. A common
    pitfall is to forget that datetimes always include a time component as
    well as a date component. If you don't supply the time, SQL Server will
    assume midnight as default. The above query is comparing a.entry_date to
    '2004-11-03T00:00:00.000' and won't match is a.entry_date is equal to
    (e.g.) '2004-11-03T16:45:00.000'. If you want to find all rows with
    entry_date 20041103, regardless of the time, use a.entry_date >=
    '20041103' AND a.entry_date < '20041104'.

    Best, Hugo

    -- 
    (Remove _NO_ and _SPAM_ to get my e-mail address)
    

  • Next message: jj: "Creating a Basic SQL Model (tutorial)"

    Relevant Pages

    • Re: Which query is running
      ... GetAddress is the name of a function which combines and formats the address ... Each query could contain more than 1 output field that need parameters to be ... This is part of a Club database. ... On Error GoTo GetParameters_Err ...
      (comp.databases.ms-access)
    • Re: Parameter Query and Date calculations....
      ... the CVDATE() didn't make any difference to the records that were returned. ... append query so the calculated date is added to a field in a table with the ... I shall certainly be more careful with formats in the ... >> I am calculating a future date using the DateAdd function in a query (the ...
      (comp.databases.ms-access)
    • Re: Multiple date formats in a Table
      ... Athough you suggest doing the conversion of my original ... the query on that field... ... historical research, I located a reference for one of my ... Multiple date formats in a Table ...
      (microsoft.public.access.tablesdbdesign)
    • Re: Can I output query result to text files in QueryAnalyzer?
      ... You can send the output in file in different formats. ... In Query Analyzer goto Tools-->Options and then click Results tab and under ... save the output in a file save with .csv extension. ... Open the file in Excel. ...
      (microsoft.public.sqlserver.programming)
    • Re: time format error
      ... >but when run through QueryAnalyzer or EnterpriseManager doesn't ... Here are 2 examples of the query: ... >System.Data.SqlClient.SqlException: Line 1: Incorrect syntax near '12'. ... should also stop using ambiguous date formats. ...
      (comp.databases.ms-sqlserver)