Solved

COMBINE TWO QUERIES

Posted on 2008-10-16
2
217 Views
Last Modified: 2012-05-05
Does anyone know why I can run this queries?

SELECT "Student ID", "Student Name" FROM "STUDENT DATA"
WHERE "Crs No" = 10 UNION ALL SELECT * FROM RVM9525.course WHERE  
courseNo = 10

It's giving error massage: query block has incorrect number of result columns
0
Comment
Question by:Dhehien
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 74

Accepted Solution

by:
sdstuber earned 250 total points
ID: 22733774
RVM9525.course must have more than 2 columns

you are querying 2 columns from the first table
but you are unioning it to an unknown number of columns in the second table.
0
 
LVL 143

Assisted Solution

by:Guy Hengel [angelIII / a3]
Guy Hengel [angelIII / a3] earned 250 total points
ID: 22733778
SELECT *

is returning more that 2 columns!
either change the * into 2 columns, or add some dummy (null) values in the first part

note: SELECT * should really not be used in UNION queries...
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I'm trying, I really am. But I've seen so many wrong approaches involving date(time) boundaries I despair about my inability to explain it. I've seen quite a few recently that define a non-leap year as 364 days, or 366 days and the list goes on. …
PL/SQL can be a very powerful tool for working directly with database tables. Being able to loop will allow you to perform more complex operations, but can be a little tricky to write correctly. This article will provide examples of basic loops alon…
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…
Suggested Courses

751 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question