Join 2 qureries

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Jafrywilson
    New Member
    • Aug 2010
    • 2

    Join 2 qureries

    How to join these queries without union all

    Code:
    select f.mobid, f.merchant, f.price
    from (
       select mobid, min(price) as minprice
       from tbl_merchant group by mobid 
    ) as x inner join tbl_merchant as f on f.mobid = x.mobid and f.price = x.minprice order by mobid
    Code:
    select f.mobid, f.merchant, f.price
    from (
       select mobid, max(price) as minprice
       from tbl_merchant group by mobid
    ) as x inner join tbl_merchant as f on f.mobid = x.mobid and f.price = x.minprice order by mobid
    Urgent help me!
    Tnx in advance
    Last edited by NeoPa; Aug 24 '10, 12:20 PM. Reason: Almost all our rules broken here.
  • NeoPa
    Recognized Expert Moderator MVP
    • Oct 2006
    • 32636

    #2
    How about you ask the question a little more meaningfully than how does one join these queries. What do you actually want? What manner of join are you looking for?

    Comment

    • Jafrywilson
      New Member
      • Aug 2010
      • 2

      #3
      I need to connect these two queries into a single one

      Comment

      • NeoPa
        Recognized Expert Moderator MVP
        • Oct 2006
        • 32636

        #4
        Right axis. Wrong direction.

        It needs to be more clear rather than less.

        Comment

        • ck9663
          Recognized Expert Specialist
          • Jun 2007
          • 2878

          #5
          If you're trying to merge these two queries into one result set with both result set below the other, you're going to need UNION ALL. If you need to return as one result set with one on right of the other, you're going to need to do a JOIN. Which one are you trying to do?

          Happy Coding!!!

          ~~ CK

          Comment

          Working...