Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Database & SysAdmin
  3. Database
  4. Using two select statements in one SQL command (Oracle, Access, etc.)

Using two select statements in one SQL command (Oracle, Access, etc.)

Scheduled Pinned Locked Moved Database
questiondatabasecsharpsql-serveroracle
5 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • X Offline
    X Offline
    Xiangyang Liu
    wrote on last edited by
    #1

    With SQL Server 2000, I can execute the following SQL command: select * from table1 select * from table2 The output contains two record sets, one for each select statement. But if I do this with Oracle or MS Access (via ODBC connections), I got syntax errors. The question is, what is the correct way to execute a SQL command with two or more select statements? Is it supported by Oracle? Is there a way to get around it? Thanks. P.S. I know the problem is not with ODBC itself because I can do this with SQL Server 2000 via ODBC connection.[

    My articles and software tools

    ](http://mysite.verizon.net/XiangYangL/index.htm)

    T D 2 Replies Last reply
    0
    • X Xiangyang Liu

      With SQL Server 2000, I can execute the following SQL command: select * from table1 select * from table2 The output contains two record sets, one for each select statement. But if I do this with Oracle or MS Access (via ODBC connections), I got syntax errors. The question is, what is the correct way to execute a SQL command with two or more select statements? Is it supported by Oracle? Is there a way to get around it? Thanks. P.S. I know the problem is not with ODBC itself because I can do this with SQL Server 2000 via ODBC connection.[

      My articles and software tools

      ](http://mysite.verizon.net/XiangYangL/index.htm)

      T Offline
      T Offline
      toxcct
      wrote on last edited by
      #2

      you have to use ';' character to separate SQL statements


      TOXCCT >>> GEII power
      [toxcct][VisualCalc]

      X 1 Reply Last reply
      0
      • T toxcct

        you have to use ';' character to separate SQL statements


        TOXCCT >>> GEII power
        [toxcct][VisualCalc]

        X Offline
        X Offline
        Xiangyang Liu
        wrote on last edited by
        #3

        toxcct wrote: you have to use ';' character to separate SQL statements Thanks. I tried it, did not work. I also tried "\n" and "\r\n" without success.[

        My articles and software tools

        ](http://mysite.verizon.net/XiangYangL/index.htm)

        1 Reply Last reply
        0
        • X Xiangyang Liu

          With SQL Server 2000, I can execute the following SQL command: select * from table1 select * from table2 The output contains two record sets, one for each select statement. But if I do this with Oracle or MS Access (via ODBC connections), I got syntax errors. The question is, what is the correct way to execute a SQL command with two or more select statements? Is it supported by Oracle? Is there a way to get around it? Thanks. P.S. I know the problem is not with ODBC itself because I can do this with SQL Server 2000 via ODBC connection.[

          My articles and software tools

          ](http://mysite.verizon.net/XiangYangL/index.htm)

          D Offline
          D Offline
          DiWa
          wrote on last edited by
          #4

          if both tables are identical, you can use 'Select * from tab1 UNION Select * from tab2' in fact you can use the UNION statement whenever querys return a identical resultset. dirk

          X 1 Reply Last reply
          0
          • D DiWa

            if both tables are identical, you can use 'Select * from tab1 UNION Select * from tab2' in fact you can use the UNION statement whenever querys return a identical resultset. dirk

            X Offline
            X Offline
            Xiangyang Liu
            wrote on last edited by
            #5

            DiWa wrote: if both tables are identical Unfortunately, they are not identifical.[

            My articles and software tools

            ](http://mysite.verizon.net/XiangYangL/index.htm)

            1 Reply Last reply
            0
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • World
            • Users
            • Groups