union

Union with LINQ to XML

I need to union two sets of XElements into a single, unique set of elements. Using the .Union() extension method, I just get a "union all" instead of a union. Am I missing something? var elements = xDocument.Descendants(w + "sdt") .Union(otherDocument.Descendants(w + "sdt") .Select(sdt => ...

Creating MySQL View using UNION

Hi, I am trying to create a view for the following query. SELECT DISTINCT products.pid AS id, products.pname AS name, products.p_desc AS description, products.p_loc AS location, products.p_uid AS userid, products.isaproduct AS whatisit FROM products UNION SELECT DISTINCT services.s_id AS id...

Union or Use Flow Control Logic to Determine which table to report on

I'm working with a 3rd pary app where I can't alter the tables. We built custom matching "Monthly" tables with an additional datetime column "AsOfDate" where we dump the data at the end of the month and flag those data with the date of last day of the month. I want to be able to create a single Stored Procedure (Application is designed ...

Display mysql join/union results differently based on table

Hello, I need to generate a list of activity from multiple tables in order of the date they were entered into the tables, but when i spit them out (with php), i want each result to look specific to a design that i have for each table. ie...i have the tables: listings, photos, comments -the results from listings should be designed...

MySql UNION for UPDATE

Is there a way to update multiple rows with different values for each row using a single SQL query? I have to update one colum in many rows with different data. Using individual update queries for each row seems excessive so if it's possible I would like to consolidate this process into a single SQL statement or at least reduce the numbe...

How can I order entries in a UNION without ORDER BY?

How can I be sure that my result set will have a first and b second? It would help me to solve a tricky ordering problem. Here is a simplified example of what I'm doing: SELECT a FROM A LIMIT 1 UNION SELECT b FROM B LIMIT 1; ...

Expand query beyond that specifed in the WHERE clause

There must be a better way of writing this query. I want to select all the data between a pair of dates. Ideally the first and last rows of the result set would be those specifed in the WHERE clause. If those rows don't exist, I want the rows preceeding and following the requested range. An example: If my data is: ... 135321, 20090...

Updateable view in mssql with multiple tables and computed values

Huge database in mssql2005 with big codebase depending on the structure of this database. I have about 10 similar tables they all contain either the file name or the full path to the file. The full path is always dependent on the item id so it doesn't make sense to store it in the database. Getting useful data out of these tables goes a...

LINQ to SQL doing a Union and Left Outer Join

I have 3 tables. 2 contain lists of files that I need to do a UNION on to get all the unique files, then I want to do a left outer join against the 3rd table to find all the files that are in the 3rd table only and not in the other 2. To do the UNION I have the following: var imageUnion = (from img in dc.ImageT1 selec...

C++ union array and vars?

There's no way to do something like this, in C++ is there? union { { Scalar x, y; } Scalar v[2]; }; Where x == v[0] and y == v[1]? ...

Unions in C

The idea behind this question is to understand the deeper concepts of using union and using it in different way so as to save memory.. My question to all is-- lets say there is structure struct strt { float f; char c; int a; } and the same structure represented in union union unin { float f; char c; int a; } Now...

Examples of Union in C

I'm looking for some union examples, not to understand how union works, hopefully I do, but to see which kind of hack people do with union. So feel free to share your union hack (with some explanation of course :) ) ...

sizeof a union in C/C++

What is the sizeof the union in C/C++? Is it the sizeof the largest datatype inside it? If so, how does the compiler calculate how to move the stack pointer if one of the smaller datatype of the union is active? ...

Is it possible to put several objects together inside a union?

What if I have this: union{ vector<int> intVec ; vector<float> floatVec ; vector<double> doubleVec ; } ; Of course, I'll be using just one of the 3 vectors. But... what happens when all the 3 vectors are contructed?? Would the consructors of the 3 vectors interfere with each other?? (since the 3 of them are in the same mem...

Group Union

I have the following query that always give me two rows. I want to group them to one row using tbluser.userid, is it possible to group a union? SELECT SUM(tblfooditem.calories) FROM tblfooditem INNER JOIN tbluser ON tblfooditem.userid = tbluser.userid WHERE tblfooditem.userid=?userid AND tblfooditem.date=?date GROUP BY tbluser.user...

mysql explain in a union query

Hi, After performing EXPLAIN on a query: explain select name from t1 where name like '%smthing%' UNION ALL select name from t2 where name like '%smthing%' UNION ALL select name from t3 where name like '%smthing%' UNION ALL select name from t4 where name like '%smthing%' composed by the UNION of 4 tables I get this: id select_type...

SQL: Using Top 1 in UNION query with Order By

I have a table as below Rate Effective_Date ---- -------------- 5.6 02/02/2009 5.8 05/01/2009 5.4 06/01/2009 5.8 12/01/2009 6.0 03/15/2009 I am supposed to find the all rates that are effective for current date and after it. So to get the current effective rate, i use SELECT TOP 1 * from table where effective_date < '05/05/2009...

C# equivalent to C union

Duplicate of http://stackoverflow.com/questions/126781/c-union-in-c Is there a C# equivalent to the C union typedef? What is the equivalent of the following in C#? typedef union byte_array { struct{byte byte1; byte byte2; byte byte3; byte byte4;}; struct{int int1; int int2;}; };byte_array ...

How do I access internal members of a union?

I have a union that is defined like this: typedef union { enum { REVISION = 0, CURRENT_VERSION = REVISION }; enum FLAGS{ FLAG_DEFAULT = 0x00000000, FLAG_EOD = 0x00000001, FLAG_OUTOFORDER = 0x00000002 }; CHAR _filler[32]; struct INTERNAL_STRUCTURE { UINT16 ...

Union – useless anachronism or useful old school trick?

I recently came across a great data structures book,"Data Structures Using C" (c) 1991, at a local Library book sale for only $2. As the book's title implies, the book covers data structures using the C programming language. I got the book knowing it would be out-dated but would probably contain lots of advanced C topics that I wouldn't...