combining the results of two selects...

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Laldie
    New Member
    • Mar 2008
    • 2

    combining the results of two selects...

    Hi,

    I have two similar but not exactly the same tables binding to gridviews in .net

    i currently use two selects to get the data i need,

    can I create a view or stored proc to combine the data and display on one gridview? (preferably sorted by xdate)

    my sql is


    Query1
    SELECT id, gsm, pin, lat, long, xtime, Org, network, type, accuracy FROM lbspings WHERE (gsm = '') Or (gsm = '') Or (gsm = '') Or (gsm = '447814486282') Or (gsm = '') ORDER BY xtime DESC;

    Query2
    SELECT id, deviceid AS gsm, pin, Lat, Long, xtime, Placename AS Org, network, pingtype AS type, accuracy FROM gpspings WHERE (deviceid = '') Or (deviceid = '') Or (deviceid = '') Or (deviceid = '') Or (deviceid = '') ORDER BY xtime DESC;

    I'm relatively new to mssql server and have wasted days on this...

    Regards,

    Laldie
  • Laldie
    New Member
    • Mar 2008
    • 2

    #2
    One of those moments,

    SQL1

    UNION ALL

    SQL2

    :-)

    Laldie

    Comment

    Working...