SQL statement using two tables

Discussion in 'ASP General' started by Maximus, Mar 19, 2007.

  1. Maximus

    Maximus Guest

    I need some help with a SQL statement. I currently have which works:

    strSQL = "SELECT * FROM mstJobs WHERE JobStatus = True"

    I need to query against a second table but I am not sure of the
    correct syntax of the statement for adding another table.. somthing
    like this i would imagine... ????

    strSQL = "SELECT * FROM mstJobs.pmdata WHERE JobStatus = True AND
    WHERE WeekEnding IN tblSuperInput.pmdata = strThursday"

    Any help or direction would be appreciated.

    Thanks
    Maximus, Mar 19, 2007
    #1
    1. Advertising

  2. Maximus wrote:
    > I need some help with a SQL statement. I currently have which works:
    >
    > strSQL = "SELECT * FROM mstJobs WHERE JobStatus = True"
    >

    Don't ask a database-related question without telling us what database
    type and version you are using.

    Given that "WHERE JobStatus = True " does not raise an error, I am going
    to assume you are using a Jet (Access) database.

    > I need to query against a second table but I am not sure of the
    > correct syntax of the statement for adding another table.. somthing
    > like this i would imagine... ????
    >
    > strSQL = "SELECT * FROM mstJobs.pmdata WHERE JobStatus = True AND
    > WHERE WeekEnding IN tblSuperInput.pmdata = strThursday"
    >


    No, probably not at all like this. However, we cannot answer this
    question. We don't know which table has the WeekEnding field, or what
    the datatype of that field is. Also, what table contains the strThursday
    field? And is pmdata a table or field?

    When asking how to create a query you should provide
    1. the schemas for the tables involved in the query. By "schema", I mean
    the names and datatypes of the fields involved in the query (if you have
    a 50-field table, the quickest way to make us ignore your post is to
    provide all 50 field names when you are only using 5 of them in your
    query)
    2. Some sample data in tabular format
    3. The data that the query should retrieve from that sample data - again
    in tabular format
    4. A short explanation of why the data shown in step 3 should be
    retrieved (<grin> and no, "because that's the data I want" will not
    suffice)
    5. If you've already made an unsuccessful attempt, show the sql you
    attempted and show the results you obtained (again, in tabular format),
    explaining why the results are incorrect - yes, I know this does not
    apply to your current problem

    --
    Microsoft MVP -- ASP/ASP.NET
    Please reply to the newsgroup. The email account listed in my From
    header is my spam trap, so I don't check it very often. You will get a
    quicker response by posting to the newsgroup.
    Bob Barrows [MVP], Mar 19, 2007
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. dna
    Replies:
    1
    Views:
    1,270
  2. William \(Bill\) Vaughn
    Replies:
    0
    Views:
    441
    William \(Bill\) Vaughn
    Aug 21, 2003
  3. David Browne
    Replies:
    0
    Views:
    454
    David Browne
    Aug 21, 2003
  4. TN Bella
    Replies:
    1
    Views:
    460
    TN Bella
    Jun 15, 2004
  5. Paolo

    Two dropdownlist and two tables...

    Paolo, Sep 19, 2006, in forum: ASP .Net Web Controls
    Replies:
    0
    Views:
    132
    Paolo
    Sep 19, 2006
Loading...

Share This Page