union

Getting a distinct value across 2 union sql server tables...

I know this is a silly question, but Im a newb I'm trying to get all distinct values across 2 tables using a union... The idea is to get a count of all unique values in the columnA column without repeats so that I can get a summation of all columns that contain a unique columnA... sounds simple eh? THis is what I tried (sql server expr...

PInvoke returns C type with union

How would I P/Invoke a C function which returns a union'ed struct? ...

Avoiding union by join?

Hi, My problem is on Oracle, but is probably database independent (?). I have the following tables: aa vid cb --- -- 1 10 2 15 bb vid cb --- -- 3 25 4 24 *rep repid vid p ----- --- -- 99 1 aa 99 2 aa 99 3 bb 99 4 bb The column p indicates in which table to get the row....

Use of a Union to avoid Dynamic Allocation Headaches

I'm curious if it's a good idea to use a union when accessing Win32 APIs that return variable length structures, to avoid manually managing the allocated memory. Consider the following: void displayServices(std::wostream& log, std::tr1::shared_ptr<void> manager, LPENUM_SERVICE_STATUS currentServiceToDisplay, DWORD number, bool whitelis...

Problems with a Union Query with an image/varbinary field

I'm having some problems with the following Query: SELECT v.idnum ,v.full_name ,convert(varbinary(max),s.signature) as Sig FROM AppDB.dbo.v_People1 AS v INNER JOIN OtherDB.dbo.Signatures AS s ON v.idnum = s.idnum UNION SELECT v.idnum , v.full_name , convert(varbinary(max), s.signatu...

C: Where is union practically used?

I have a example with me where in which the alignment of a type is guaranteed, union max_align . I am looking for a even simpler example in which union is used practically, to explain my friend. ...

using union in yacc for structures

Hi I'm a little confused about how to specify my grammar member's type. I want to declare prog and decls as ASTNode. I'm gonna use these members for adding to a list or etc. But yacc can't recognize them as an ASTNode and I get type errors. Here my tIdent,tCharConst,tIntConstant have some types but, how to give ASTNode type to my membe...

How to use anonymous structs / unions in c?

I can do this in c++/g++: struct vec3 { union { struct { float x, y, z; }; float xyz[3]; }; }; Then, vec3 v; assert(&v.xyz[0] == &v.x); assert(&v.xyz[1] == &v.y); assert(&v.xyz[2] == &v.z); will work. How does one do this in c with gcc? I have typedef struct { union { st...

Cannot marshal a struct that contains a union

I have a C++ struct that looks like this: struct unmanagedstruct { int flags; union { int offset[6]; struct { float pos[3]; float q[4]; } posedesc; } u; }; And I'm trying to Marshal it like so in C#: [StructLayout(Layou...

Programming a custom union in C# (join between many objects)

Scenario I need to build a table of data from a list of objects given a specification. In example, I have a list/array of Order objects, and a string specification detailing what the data table should contain e.g "ID;Date;Customer.ID;Customer.Name;Orderlines.Product.ID;Orderlines.Quantity;Orderlines.UnitPrice". The order class class co...

TSQL: union results from two selects (procedures?)

I have two procedures - two huge sets of selects with several sub-select and unions. I need to union results from these procedures and I still need them to exists separately. Something like that: if @Param = 1 Then PROCEDURE1 if @Param = 2 THEN PROCEDURE2 if @Param = 3 Then PROCEDURE1 union PROCEDURE2 I read that it's i...

UNION with codeigniter's active record

Hi all How to do UNION query with codeigniter's active record? ...

SQL mapping between multiple tables

This is a SQL design question. First, the setup. I have three tables: A, which is automatically populated based on a query against a linked server. The data in this table cannot be changed; B, which has just a dozen or so rows, containing the names for collections of A's; AtoB, which is the mapping table by which A's are organized into...

How can I return a list of all tables in a database with column hostname that contain hostname=hostA

I can get all the tables containing column 'hostname' using: select select table_name from information_schema.columns where column_name='hostname'; If I knew the names of all the tables I could use a union like: SELECT * FROM ((SELECT hostname FROM table1) UNION (SELECT hostname FROM table2) ... UNION (SELECT hostname ...

Using array of chars as an array of long ints

On my AVR I have an array of chars that hold color intensity information in the form of {R,G,B,x,R,G,B,x,...} (x being an unused byte). Is there any simple way to write a long int (32-bits) to char myArray[4*LIGHTS] so I can write a 0x00BBGGRR number easily? My typecasting is rough, and I'm not sure how to write it. I'm guessing jus...

Union in SQL Server 2005

Hi guys, The following is my query Select vehicleID from trip where (StartingDate between ''+ convert(varchar(10), @StartDate,111) +'' and ''+ convert(varchar(10), @EndDate,111)+'') or (enddate between ''+ convert(varchar(10), @StartDate,111) +'' and ''+ convert(varchar(10), @EndDate,111)+'') or(StartingDate <= @StartDate and enddate...

More efficient SQL than using "A UNION (B in A)"?

Edit 1 (clarification): Thank you for the answers so far! The response is gratifying. I want to clarify the question a little because based on the answers I think I did not describe one aspect of the problem correctly (and I'm sure that's my fault as I was having a difficult time defining it even for myself). Here's the rub: The result s...

Can a union be initialized in the declaration?

For example, say we have a union typedef union { unsigned long U32; float f; }U_U32_F; When a variable of this union type is declared, is there a way to set an initial value? U_U32_F u = 0xffffffff; // Does not work...is there a correct syntax for this? ...

How to limit an SQL result set to not too common items

Problem: I have a list of names and addresses. Some names (persons) have the same address (street, zip code, town) like others. I want to select all those names with addresses with no more than three occurrences and from the rest the first three names each of a bunch pointing to the same address. Example: Albert | Adr1 Berta | Adr1 Cesa...

How can I write this MYSQL query without using UNION?

I'd like to do a single query on one table without using UNION Here are the two queries that I need to combine. SELECT field1, field2, field3 FROM table1 WHERE field4 != 'condition1' AND feild3 >= 'condition2' ORDER BY field3 ASC LIMIT 20; SELECT field1, field2, field3 FROM table1 WHERE field4 != 'condition1' AND feild3 < 'condition2' ...