Solved

COMBINE TWO QUERIES

Posted on 2008-10-16
2
201 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
2 Comments
 
LVL 73

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 142

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

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

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

Suggested Solutions

If you have heard of RFC822 date formats, they can be quite a challenge in SQL Server. RFC822 is an Internet standard format for email message headers, including all dates within those headers. The RFC822 protocols are available in detail at:   ht…
This article describes how to use the timestamp of existing data in a database to allow Tableau to calculate the prior work day instead of relying on case statements or if statements to calculate the days of the week.
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

810 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