Most voted "union" questions
A Union is a type of object that is capable of saving memory using a single region of it to store different data at different times. A Union can also refer to the joining of two things, most often being the joining of two tables. Use this tag when the question refers to one of the two situations.
Learn more…25 questions
Sort by count of
-
18
votes3
answers10342
viewsWhat are Unions? Why use them within structs?
I’d like to understand the differences between union and struct. I realized that both can be accessed in the same way: u.membro uPrt->membro s.membro sPrt->membro In practice I have seen…
-
15
votes2
answers10671
viewsWhat’s the difference between Union and Union All?
What’s the difference between UNION and UNION ALL? If possible, include examples of use.
-
14
votes2
answers128
viewsWhat are they and when to use Anonymous Unions?
During the data structure book reading, it was briefly presented the concept of anonymous unions, which would be the definition of a union without specifying a label (name). However, I did not…
-
5
votes1
answer98
viewsCan Union and struct be considered operators?
One union or a struct can be considered operators? As well as return, goto and sizeof?…
-
4
votes1
answer89
viewsIs it possible to replicate a Union in Java?
As unionthe ones I’m talking about are the same as C/C++. The goal of union is to save memory using the same region of it to store different data at different times. It’s like a hotel room.…
-
1
votes2
answers104
viewsDoubt in the elaboration of a query in SQL
Could you tell me what’s wrong with this SQL code? I want for each film, the wages of each staff do not appear repeated, that is, if in the first film has 2 leads, in the table I want the sum of…
-
1
votes3
answers55
viewsI tried a Union consultation but did not get the expected result
I made a query with two selects using union and it has two columns: MOBI and DESMOBI. I need the result to show these two columns. when I run it shows only the column MOBI`. Below follows the query.…
-
1
votes1
answer68
viewsStruct with Union is giving invalid usage error
I need to use a union within a struct, but I’m not getting it. The error presented is [Error] invalid use of 'Union Client::document' Struct: struct Cliente{ string nome, email; union documento{…
-
1
votes1
answer191
viewsLaravel 5.5: Pick name of each table in select Union
I need to make a select in two tables and join them with the union, until then, but I also need to take the name of the two View. I’ve tried using the getTable() in each select, but it returns me…
-
1
votes1
answer132
viewsMerge two IF or more
I need to unite some if's and I’m having difficulties, I’ve tried using with the union, but to no avail. The query I’m running is: IF (select count(Estado) FROM tbl_1 where Estado != 'WIP' AND…
-
1
votes1
answer208
viewsUNION - SQL Server
I’m trying to make an appointment with Union, and it returns the following error message: Message 5335, Level 16, Status 1, Line 1 The type of text data cannot be used as an operand for UNION,…
-
1
votes1
answer40
viewsDoubt - SQL Server - Using Union
Guys, I got the following Union: select cgc, item, matricula, cota, dataInicio, dataFim from [dbo].[cotas] as t1 where dataFim is null union select cgc, item, matricula, cota, dataInicio, dataFim…
-
1
votes1
answer675
viewsWhat is the difference between JOIN and UNION in SQL?
What’s the difference between JOIN and UNION in SQL? I thought a query made with either of the two would result in the same table, but I’m taking a course at Datacamp where the teacher says these…
-
1
votes0
answers24
viewsTreat Undefined binary code reading behavior as different types
They say that this inline function code has "Undefined behavior", either by binary codes of the same meaning in float and different in other types, or because the order of storage and use of the…
-
1
votes1
answer66
viewsHow to join the select of these 3 tables that have no connection at all?
The image below shows 3 tables, united by Excel. The first is called customer, the second representative and the third is called channel. But I would like to join them in a single select in sql, and…
-
0
votes1
answer37
viewsHow to join two results in a conditional query
Talk, you guys! Would anyone know how to use a Union All on parole? Example: DECLARE @cond INT = 1 SELECT * FROM table1 IF(@cond = 1) BEGIN UNION ALL SELECT * FROM table2 END The idea is this but…
-
0
votes0
answers278
viewsAlternative to using UNION in mysql/php
Good morning, I am doing the sum of the elements of a column (I called Minhacoluna) in function of another, called "turn". There are three values for turn, so I need the code to return three…
-
0
votes1
answer46
viewsTrouble joining tables with UNION
I am trying to bring the top 3 of my table and also the last 2 placed, SITE TO EXECUTE SCRIPT This is my current progress that doesn’t work SELECT ('Podium: ' ||TEAM) as name FROM LEAGUE ORDER BY…
-
0
votes2
answers335
viewsUnion problem in mysql
I am trying to perform a query and is giving the following error: Unknown column 'BRANCH' in 'field list' The consultation is as follows:: SELECT TICKET, DATAHORA, TIPO, ESTADO, CRITICIDADE, LOGIN,…
-
0
votes3
answers55
viewsSwitch between results
Hello! I have the following appointments: SELECT id, nome, idade, data_nascimento, cpf FROM internos WHERE cpf = '12345678911' and SELECT id, nome, idade, data_nascimento, cpf FROM externos WHERE…
-
0
votes2
answers84
viewsUnion All specify select no order by
I have ONE test table and I’m doing a Union All and I want to sort by date but not sort by the first select before Union All which would be a headline. I would like to order only the data of the…
-
0
votes2
answers40
viewsUsing formula in SQL
Hello, I’m having a doubt and I can not find examples to progress, following: select 'disponivel' as TIPO , COUNT(distinct dp.ds_nome) as qtd FROM dm_pessoa_treino dp union ALL select 'em_uso' as…
-
0
votes1
answer50
viewsSegmentation failure - C
#include <stdio.h> #include <stdlib.h> #include <string.h> int validaTipo(char t); typedef union{ struct contratoIndividual{ unsigned int…
-
0
votes2
answers48
viewsMysql - Add values from a column and also bring value from each row
I have a certain column and need to return both the sum of the values of the same, as well as the individual values of each row. I did a test with UNION and even worked, the first line returned to…
-
0
votes1
answer34
viewsUNION is not consolidating SOMA between 2 Postgresql tables
I’m new here and I’m looking for a solution to this problem. I have two tables that add production values per hour of two different teams, however, with the UNION occurs the duplication of lines…