Results 1 to 8 of 8

Thread: SQL problem- can it be done??

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Nov 2001
    Location
    ottawa, canada
    Posts
    233

    SQL problem- can it be done??

    Is it possible to Merge the 2 queries below in to one querie.


    strSQL = "Select * From CALIBRECORDS where InstrumenNumber = " & "'" & Form1.Text2.Text & "'"




    strSQLq = "Select Instrumentdescription From Guages where InstrumenNumber = " & "'" & Form3.Text49.Text & "'"

    i have 2 fields in 2 diferent tables that i would like to have on one form.

    Any help would be appreciated

  2. #2
    PowerPoster
    Join Date
    Oct 2002
    Location
    British Columbia
    Posts
    9,758
    Sure, try something like this.

    VB Code:
    1. strSQL = "Select C.*, G.Instrumentdescription
    2. From CALIBRECORDS C Join Guages G On C.InstrumenNumber  = G.InstrumenNumber
    3. Where C.InstrumenNumber = '" & Form3.Text49.Text & "'"

  3. #3
    Hyperactive Member maxl's Avatar
    Join Date
    Jan 2002
    Location
    Montréal
    Posts
    384
    Is there a link between the 2 tables ?
    COBOL sa suce !!!

  4. #4

    Thread Starter
    Addicted Member
    Join Date
    Nov 2001
    Location
    ottawa, canada
    Posts
    233
    Thanks brucevde for your suggestion, However, i cant get your code to work, i get a syntax error.

    Also, there is no mention of form3.text2.text in your code.

    I am a newbie to databases, so can you please keep any replies simple.

    Thanks mate.


    maxl,

    The link between the 2 tables is the instrument number.

  5. #5
    Hyperactive Member
    Join Date
    Oct 2000
    Posts
    303

    Try this

    SELECT
    A.column1, A.column2,
    B.Instrumentdescription
    FROM InstrumenNumber as A,
    Guages as B
    WHERE
    A.InstrumenNumber = B.InstrumenNumber

    Replace column1 and column2 with your desired columns from
    table InstrumenNumber!

  6. #6

    Thread Starter
    Addicted Member
    Join Date
    Nov 2001
    Location
    ottawa, canada
    Posts
    233
    Thanks for reply, but what do you mean by column1 and column 2?

    Am i missing something basic?

    Please enlighten me.

    Thanks

  7. #7
    Hyperactive Member maxl's Avatar
    Join Date
    Jan 2002
    Location
    Montréal
    Posts
    384
    Originally posted by sparkash
    Thanks brucevde for your suggestion, However, i cant get your code to work, i get a syntax error.

    Also, there is no mention of form3.text2.text in your code.

    I am a newbie to databases, so can you please keep any replies simple.

    Thanks mate.


    maxl,

    The link between the 2 tables is the instrument number.
    VB Code:
    1. strSQL = "SELECT C.*,  G.InstrumentDescription FROM CaliberRecords C INNER JOIN Guages G ON C.InstrumenNumber=G.InstrumenNumber WHERE C.Id_InstrumenNumber=" & txtInstrumenNumber.Text
    COBOL sa suce !!!

  8. #8
    Hyperactive Member
    Join Date
    Oct 2000
    Posts
    303
    what I mean is the actual column name from table A. If you
    want all of them, just use * and it should be fine.

    SELECT
    a.*
    B.Instrumentdescription
    FROM InstrumenNumber as A,
    Guages as B
    WHERE
    A.InstrumenNumber = B.InstrumenNumber

    P.S. I am leaving for home but if you can't get it just
    let me know by Monday.

Posting Permissions

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



Click Here to Expand Forum to Full Width