union

Implementing union of Set using basic java array

Note: This is an assignment. Hi, Continuing with my Set implementation using Java basic array, I'm now struggling with the 3 to last function namely the union. import java.io.*; class Set { private int numberOfElements = 0; private String[] setElements = new String[5]; private int maxNumberOfElements = 5; ...

How to differenciate the data when doing a UNION on 2 SELECTS ?

If I have the following two tables : Employes Bob Gina John Customers Sandra Pete Mom I will do a UNION for having : Everyone Bob Gina John Sandra Pete Mom The question is : In my result, how can I creat a dumn column of differenciate the data from my tables ? Everyone Bob (Emp) Gina (Emp) John (Emp Sandra (Cus) Pete (Cu...

LINQ to Objects .Distinct() not pulling distinct objects

I have two ways that I am doing a fuzzy search for a customer. One is by an abbreviated name and the other is by the customer's full name. When I take these two result sets and then union them together (which I have read several places should remove distinct values) I get duplicates. Thinking that all I need to do is then call the .Disti...

Java constructor and modify the object properties at runtime

Note: This is an assignment Hi, I have the following class/constructor. import java.io.*; class Set { public int numberOfElements = 0; public String[] setElements = new String[5]; public int maxNumberOfElements = 5; // constructor for our Set class public Set(int numberOfE, int setE, int maxN...

Seeking C Union clarity

typedef union { float flts[4]; struct { GLfloat r; GLfloat theta; GLfloat phi; GLfloat w; }; struct { GLfloat x; GLfloat y; GLfloat z; GLfloat w; }; } FltVector; Ok, so i think i get how to use this, (or, this is how i have seen it used) ie. FltVector ...

Using unions to simplify casts

I realize that what I am trying to do isn't safe. But I am just doing some testing and image processing so my focus here is on speed. Right now this code gives me the corresponding bytes for a 32-bit pixel value type. struct Pixel { unsigned char b,g,r,a; }; I wanted to check if I have a pixel that is under a certain value (e.g...

Is the use of union in this matrix class completely safe?

Unions aren't something I've used that often and after looking at a few other questions on them here it seems like there is almost always some kind of caveat where they might not work. Eg. structs possibly having unexpected padding or endian differences. Came across this in a math library I'm using though and I wondered if it is a total...

gcc, strict-aliasing, and casting through a union

Do you have any horror stories to tell? The GCC Manual recently added a warning regarding -fstrict-aliasing and casting a pointer through a union: [...] Taking the address, casting the resulting pointer and dereferencing the result has undefined behavior [emphasis added], even if the cast uses a union type, e.g.: union a_union...

creating a union branch of a number of git branches

I'd like to be able to layer other branches on top of an existing branch, and have those branches be revisioned independently. This would be useful, for example, to allow the binaries for various subprojects to be unified into the same bin directory. In general a given file would only be present in one layer. Ideally I guess I would u...

Combining query rows in a loop

I have the following ColdFusion 9 code: <cfloop from="1" to="#arrayLen(tagArray)#" index="i"> <cfquery name="qryGetSPFAQs" datasource="#application.datasource#"> EXEC searchFAQ '#tagArray[i]#' </cfquery> </cfloop> The EXEC executes a stored procedure on the database server, which returns rows of data, depending on what...

Merge two rows in SQL

Assuming I have a table containing the following information: FK | Field1 | Field2 ===================== 3 | ABC | *NULL* 3 | *NULL* | DEF is there a way I can perform a select on the table to get the following FK | Field1 | Field2 ===================== 3 | ABC | DEF Thanks Edit: Fix field2 name for clarity ...

Problematic behavior of Linq Union?!

Hi, consider the following example: public IEnumerable<String> Test () { IEnumerable<String> lexicalStrings = new List<String> { "test", "t" }; IEnumerable<String> allLexicals = new List<String> { "test", "Test", "T", "t" }; IEnumerable<String> lexicals = new List<String> (); foreach (String s i...

mySQL query: How to insert with UNION?

Hi everybody, I am kind of new to mySQL:s union functions, at least when doing inserts with them. I have gotten the following to work based upon a example found on the net: INSERT INTO tableOne(a, b) SELECT a, $var FROM tableOne WHERE b = $var2 UNION ALL SELECT $var,$var Ok, nothing strange about that. But what happens when I want ...

union on the same table

I have a table: ID | Id1 | Id2 1 | 100 | 12 2 | 196 | 140 3 | 196 | 141 4 | 150 | 140 5 | 150 | 199 I want to write a query that will give me a table containing records with the same ID2 and with id1 equal to 196 or 150. I thought about union: select * from table where ID1 = 196 union select * from table where ID1 = 150 ...

Problem in Union Join For MySQL Query

hey guys i managed to select from a table that saves my latest posts but i need to have double condition in selection here is my code : $sql_query = "SELECT b.*,u.username AS MY_Sender FROM TABLE_users u,TABLE_blogs b Where b.reciever = '0' AND u.user_id = b.sender UNION SELECT b.*,u.username AS MY_reciever FROM TABLE_users u,TABL...

how can i query a table that got split to 2 smaller tables? Union? view ?

hello friends, I have a very big table (nearly 2,000,000 records) that got split to 2 smaller tables. one table contains only records from last week and the other contains all the rest (which is a lot...) now i got some Stored Procedures / Functions that used to query the big table before it got split. i still need them to query the u...

When doing a UNION in mysql how can I do a where on the results

Hi I am doing a union over several tables. It's a little long but works! (SELECT user_id,added_date,group_id,'joined',0,0,'' FROM group_members WHERE status = 1) UNION (SELECT user_id,added_date,object_id,'made a comment',0,0,'' FROM comments WHERE object_type = 11 AND status = 1) UNION (SELECT user_id,added_date,group_id,'made the even...

HQL: Union selects

Hi guys, I have a forum-like system where a user has an access group and a post can be accessed by an access group. A post is of a category type, and I'd like to make a list of the category names with the number of posts the user has written in this category in a paranthesis. A user may not have access to all his posts, because one acce...

How can I add a column to this union result?

I have this query (which I removed some keys from for brevity's sake): SELECT id as in_id, out_id, recipient, sender, read_flag FROM received WHERE recipient=1 UNION ALL SELECT in_id, id AS out_id, recipient, sender, read_flag FROM sent WHERE sender=1 Which combines the results from two tables showing messages sent and recei...

Statically initialize anonymous union in C++

I am trying to statically initialize the following structure in Visual Studio 2010: struct Data { int x; union { const Data* data; struct {int x; int y; }; }; }; The following is fails with error C2440: 'initializing' : cannot convert from 'Data *' to 'char'. static Data d1; static Data d = {1, &d1}; static Da...