[Solved] SELECT UNION problem

Discuss the database features
Post Reply
Hypno
Posts: 21
Joined: Tue Jun 14, 2022 12:47 pm

[Solved] SELECT UNION problem

Post by Hypno »

I have a problem with SQL and select union.
I have 2 simple SQL queries that I converted to views.
When I do

select pesel from v_person0

and separation

select pesel from v_person1

everything works separately (already on views), but if I want to make a union, this command:

select pesel from v_person0
union select pesel from v_person1


doesn't work anymore. I get the message 'The specified command is not a SELECT statement. Only queries are allowed. "SELECT "pesel" FROM "v_person0" UNION SELECT "pesel" FROM "v_person1" '
Of course, the PESEL field in both parts is of the same type.

I create SQL with union as a direct SQL command without any wizards. What's the problem?
Last edited by MrProgrammer on Mon May 15, 2023 3:13 pm, edited 2 times in total.
Reason: Tagged ✓ [Solved] -- MrProgrammer, forum moderator
LibreOffice 7.2.2.1 (x64), Windows 10
Hypno
Posts: 21
Joined: Tue Jun 14, 2022 12:47 pm

Re: Select union problem

Post by Hypno »

I solved the problem and I'm terrified...

Select pesel From v_osoba0 UNION ALL Select pesel From v_osoba1

not working but now

Select "pesel" From "v_person0" UNION ALL Select "pesel" From "v_person1"

works well. It turns out that in a slect union, field and table names must be in quotation marks.
LibreOffice 7.2.2.1 (x64), Windows 10
User avatar
Villeroy
Volunteer
Posts: 31279
Joined: Mon Oct 08, 2007 1:35 am
Location: Germany

Re: [Solved]Select union problem

Post by Villeroy »

Query menu: Edit>"Run SQL directly"
viewtopic.php?t=9871
(parsed mode vs. direct mode (aka "pass through")
Please, edit this topic's initial post and add "[Solved]" to the subject line if your problem has been solved.
Ubuntu 18.04 with LibreOffice 6.0, latest OpenOffice and LibreOffice
Post Reply