Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Problem with UNION in SQL-Select 1

Status
Not open for further replies.

SGLong

Programmer
Jun 6, 2000
405
US
This very simple SQL-Select clause is giving me a "Command is missing required clause" error. I've compared my command to the help file for construction but nothing jumps out as being missing. Does anybody know what I'm doing wrong?

Code:
cFnCode = 'A1'   && Bank account code reference
SELECT SPACE(13) as codeval, 'BLANK for ALL' as descript ;
	UNION select subaccount AS codeval, acctdesc AS descript ;
		FROM cashacct ;
			WHERE fncode=cFnCode ;
	ORDER BY codeval ASC ;
	INTO CURSOR cur_subacct

BTW, this is for VFP 7

Steve
 
Steve,

The "missing clause" is your FROM clause in the first SELECT.

You need something like this:

Code:
cFnCode = 'A1'   && Bank account code reference
SELECT SPACE(13) as codeval, 'BLANK for ALL' as descript ;
    [b]FROM SomeTable ;[/b]
    UNION select subaccount AS codeval, acctdesc AS descript ;
        FROM cashacct ;
            WHERE fncode=cFnCode ;
    ORDER BY codeval ASC ;
    INTO CURSOR cur_subacct

Give it a try.

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

My Visual FoxPro site: www.ml-consult.co.uk
 
Thanks Mike... Since the first SELECT clause was not based upon information in a table I didn't think that the "FROM" clause was necessary. I added a reference to one of our other tables and DISTINCTs and it came up with exactly what I wanted.

Steve
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top