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
1 answer

How union data storing works. Getting confusing output

I could not understand how Union is printing data. #include int main(){ union Values{ int a; char b; int c; }; union Values val; val.a = 1; val.b= 2 ; val.c = 300; printf("%d,%d,%d",val.a,val.b,val.c); return 0; } I getting output…
Anis Mulla
  • 75
  • 7
1
vote
5 answers

Group select statements together by common column in sql-server

I need to combine two tables together based on a common column. Normally I would just use an inner join on the specific column (lets call it parentID), but I need the results to be in seperate rows. Table A: ID, ... Table B: ID, ParentID,…
Eike S
  • 300
  • 1
  • 11
1
vote
1 answer

Mysql - Union two querys with "where in" subselects

I have to find sku's (identifier) that are not listed in our catalog. Querys is simple SELECT sku FROM stock WHERE sku NOT IN (SELECT sku FROM catalog) but there might be also missing sku's in table sale SELECT DISTINCT sku FROM sale …
ABSimon
  • 651
  • 1
  • 6
  • 18
1
vote
1 answer

field has incomplete type - unions & structs

I have these types: struct netlib_nw { int id; union netlib_op op; }; union netlib_op { struct netlib_op_readdir op_readdir; struct netlib_op_readdir_recv op_readdir_recv; }; struct netlib_op_readdir { char* path; }; struct…
Martin Fischer
  • 469
  • 1
  • 7
  • 21
1
vote
1 answer

create view joining two tables having same columns without duplicates

Can anyone please help me on how to create view joining two tables having same columns without duplicates? Example: I have two tables T1 and T2 T1 Id Name Date ----------------------- 1 AAA 2019-04-05 2 BBB 2019-04-06 3 CCC…
LHS
  • 77
  • 5
1
vote
2 answers

Type mismatch when combining two SQL queries with UNION

select a,b,c, from transmission t where t.filnename ='ABC' select d,e,f, from transmission t where t.filnename ='ABC' I want the results as two rows together into one resultset as result will go into DFF report. Output Should be: a,b,c …
Sanjay Kumar
  • 27
  • 10
1
vote
2 answers

How to group unioned dataframe to combine same rows

I have just unioned two dataframes in pyspark and instead of it combining the rows with the same dates, it stacked them on top of each other like so: df1: +----------+------------+--------------+ | date| bounceCount| …
1
vote
1 answer

How can I cascade union OGR Multipolygons

I have 2 OGR Multipolygons that intersect, hence I want to cascade Union them. I tried this but it returns me empty and doesn't union it. Seems this works only on Polygons and not Mul;tipolygons. What's the best way? >>geom =…
Atihska
  • 4,803
  • 10
  • 56
  • 98
1
vote
3 answers

How to add a row to the result of a SQL query with INNER JOIN?

In times past, when I need to add a row to the result of a SQL statement, I write a statement like this: SELECT colA, colB FROM my_table UNION SELECT 'foo' AS colA, 'bar' as colB; However, suppose I've written the following SQL: SELECT…
Vivian River
  • 31,198
  • 62
  • 198
  • 313
1
vote
2 answers

Executing shell code using a function pointer present in Union

I am trying to inject shell code into the char buffer and execute it using the function pointer. both string and function pointer are in the union. Below is the shell code I am using trying to…
harsha
  • 31
  • 5
1
vote
2 answers

Yacc, structure pointers in union

For some reason, the structure pointers in a union are seemingly not defined even though I include the .h beforehand. %{ #include "agent.h" . . . %} %union {int iValue; char sIndex; ASTnode *nPtr; litNode *litPtr; ruleNode *rulePtr; exprNode…
Huzo
  • 1,652
  • 1
  • 21
  • 52
1
vote
1 answer

Better Design for eliminate duplicates after union query

I'm designing a UNION query to merge two tables with customer informations in a oracle 11g database. The first table a is the 'major' source the second table b is a additional source with new and duplicate entries. The duplicates in b can not be…
spe92
  • 23
  • 7
1
vote
1 answer

Create UNION with one or more views in MySql

I am trying to get the union of a query and a view or a view and a view. But doing this in MySql gives back an ER_PARSE_ERROR. So say I have a view called B_SAL for the state of a particular data set before a particular operation. CREATE OR…
Hakim
  • 452
  • 4
  • 15
1
vote
1 answer

How to query first and last dates

I'm querying a wildlife sightings database to display the first sighting of Dingy_Skipper based on querystring 'yr' AS Dingy_Skipper_FDate. I would like to also display the last/latest sighting from the same querystring 'yr' AS Dingy_Skipper_LDate I…
1
vote
1 answer

CakePHP 3 paginating a result from union query

I have two tables. The first one has the main products data, another one has the secondary descriptions of these products, linked by products_id foreign key on the second table. I've created the SQL and everything looks good. But when I convert to…
1 2 3
99
100