Questions tagged [union]

Use this tag only for questions about UNION, a keyword of the SQL language for combining the results of multiple SQL queries. Use [union-all] for the UNION-ALL keyword. Use the tag [unions] for unions in C, C++, and similar languages.

UNION is a keyword of SQL for combining the results of multiple SQL queries. The results are combined and duplicate rows are eliminated (similar to DISTINCT). If UNION ALL is used, the rows are combined but duplicates are not removed.

Use the tag for unions in C, C++, and similar languages. Use for the UNION-ALL keyword.

Reference

5266 questions
1
vote
2 answers

Checking for union type

I am looking for a way to have union types as function arguments, then be able to use the arguments, any missing arguments would be undefined However here, name and age are causing a type issue. function example(props: { id: number } & ({ name:…
ThomasReggi
  • 55,053
  • 85
  • 237
  • 424
1
vote
2 answers

How to get different rows from two tables in SQL Server

I'm trying to build a query that can give me the different rows between two tables. Here is my code: try { string searchquery = "SELECT* FROM NewList EXCEPT SELECT* FROM Restaurants UNION All"; SqlCommand searchcom = new…
Bora
  • 39
  • 6
1
vote
2 answers

What is better, do a union and then a join o do a join in all the tables of the union?

I have to do a union of 5 tables and then do a join with other table. Which way have more efficiency do the union of the 5 tables and then the join o do the join on each tables and then de union?.
cris2092
  • 19
  • 2
1
vote
1 answer

Difficulties using Janusgraph indexes with Gremlin UNION

I have an issue using UNION operator: in this first example the query works but gives no result: g.V().has('name','Barack Obama').union(has('name','Michelle Obama')) Instead in this second example the gremlin compiler replies that cannot use…
1
vote
1 answer

phpmyadmin accepts query while php brings error UNION and LIMIT

I have a complicated query which works FINE in phpmyadmin, but whenever I try to use it within php I get an error saying LIMIT and UNION are not allowed together. I have added LIMIT to speed up the query (so a sub-select would only look for 100…
bodomalo
  • 153
  • 1
  • 1
  • 11
1
vote
2 answers

Why are giving a union type to a variable and giving the same type to a parameter so different?

Using the tsc --strict command I get the following error: error TS2339: Property 'foo' does not exist on type 'T'. Property 'foo' does not exist on type 'Bar'. 16 console.log(obj.foo) What I don't understand is why I can assign the object…
Take
  • 324
  • 3
  • 10
1
vote
2 answers

Use column names as values for Phone Number

I have a table in which has phone numbers split out into separate columns cellphone, homephone, workphone and otherphone. I would like to do some sort of transformation which pulls all the phones into one column but shows the phone relationship in…
an1234
  • 165
  • 1
  • 12
1
vote
2 answers

Does SELECT * FROM (...union...) AS tablexyz create a temp table?

Does a query such as this create a temp table? or is it a one time use within the query? SELECT A FROM ( SELECT A, B FROM TableA UNION SELECT A, B FROM TableB ) AS tbl WHERE B > 'some value' I am using psql, and snowflake
sql_newb_1
  • 11
  • 3
1
vote
2 answers

Creat Table as Select is changing some data types

I am creating a table by selecting from another. My understanding is that by doing this, the columns created should be of the same data type as the original source. This is not the case for a couple columns and it is driving me nuts. Two columns in…
1
vote
0 answers

Why spark Data frame's union is not working with CSV data catalog in AWS glue

Iam new to AWS-glue and spark. I have to union data from a csv source and a table then load into another table using AWS glue Pyspark code. i tried by writting a code in Apache Zeppelin, its works fine here. but when i place the code and modify it…
1
vote
1 answer

SQL Joining / merging two event tables, sensitive to corresponding time

Table 1 has open times. id | OpenTime 1 | 2019-12-02 16:52:42.9130000 1 | 2019-12-02 16:55:57.5560000 1 | NULL 1 | 2019-12-02 16:59:09.5640000 1 | 2019-12-02 17:01:35.3510000 2 | 2019-12-02 17:02:55.0270000 2 | 2019-12-02 17:05:41.3930000 2 …
Rumbles
  • 113
  • 2
  • 7
1
vote
3 answers

Convex union operation in R

I have 3 vectors a = c(3,7) b = c(4,6) c = c(2,6) I would like to make the union of these 3 sets. I could use the union() function but "convex" union requires that the vector c is removed from the union because it is dominated by a, which is…
Simon
  • 349
  • 2
  • 12
1
vote
2 answers

MySQL UNION ALL is too slow

I have a query in MySQL from 4 tables. When I run these queries individually they run quick within 1 second. But when I combine them using UNION ALL, machine comes under heavy load and take at least 10 seconds for the same query in UNION ALL. And I…
Krishan Kumar
  • 394
  • 4
  • 13
1
vote
1 answer

How to simplify the query to retrieve the details in Oracle?

I need to write a query in Oracle to retrieve the details of employees who work either in Sales, Textiles and Marketing. But when the employees work in Marketing, I need to get only those employees whose department location is US and EU. The…
Anitha
  • 77
  • 1
  • 2
  • 9
1
vote
0 answers

PyCharm suggestons/completion with ctypes Structure and Union

Recently I was looking for a convenient way for defining bit fields in Python that would work similarly to those in C. I need this for registers handling in various HW components but that's less important. After some research, I did not find…
DStage
  • 33
  • 2