Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    New Coder
    Join Date
    Sep 2012
    Posts
    76
    Thanks
    61
    Thanked 0 Times in 0 Posts

    Merge a query into one?

    Hello, after some help please. I have 50 or so records in my table called values. There are two columns in this table called value1 and value2

    So I would simply query a single record like

    Code:
    Select value1, value2 From table1 Where id= 8
    Now when I have these two values I then want to perform another maths based query based on the results from the first query like so

    Code:
    Select POWER(value1,value2)
    But how do I create an all-in-one query in order to pass the results from the first quey to the second here, or is this not possible? Thank you

  • #2
    Supreme Master coder! Old Pedant's Avatar
    Join Date
    Feb 2009
    Posts
    27,128
    Thanks
    80
    Thanked 4,556 Times in 4,520 Posts
    Why would you possible need two queries?

    What is wrong with simply
    Code:
    SELECT value1, value2, POWER(value1,value2) AS myPower 
    FROM table1 WHERE id = 8
    ???
    An optimist sees the glass as half full.
    A pessimist sees the glass as half empty.
    A realist drinks it no matter how much there is.

  • Users who have thanked Old Pedant for this post:

    Oatley (05-09-2013)

  • #3
    New Coder
    Join Date
    Sep 2012
    Posts
    76
    Thanks
    61
    Thanked 0 Times in 0 Posts
    Thank you, that would make sense. My problem is though I did not explain myself very well - sorry. My second query where I use POW really part of a longer query that I cut down and did not put all the code in to avoid confusion (as it is a long complex query), which uses a different table from the first query (a table called table2).

  • #4
    Supreme Master coder! Old Pedant's Avatar
    Join Date
    Feb 2009
    Posts
    27,128
    Thanks
    80
    Thanked 4,556 Times in 4,520 Posts
    Without seeing the entire query set, I can't possibly tell how to convert it into a single query.
    An optimist sees the glass as half full.
    A pessimist sees the glass as half empty.
    A realist drinks it no matter how much there is.


  •  

    Posting Permissions

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