This piece of code compiles and runs as expected on GCC 3.x and 4.x:
#include <stdio.h>
typedef union buggedUnion
{
public:
// 4 var init constructor
inline buggedUnion(int _i) {
i = _i;
}
friend inline const buggedUnion operator - (int A, const buggedUnion &B) {
return buggedUnion(A - B.i);
}
...
I'm wanting to optimize a query using a union as a sub query. Im not really sure how to construct the query though. I'm using MYSQL 5
Here is the original query:
SELECT Parts.id
FROM Parts_Category, Parts
LEFT JOIN Image ON Parts.image_id = Image.id
WHERE
(
(
Parts_Category.category_id = '508' OR
Parts_Categ...
Is it possible to map multiple tables to a single domain model using NHibernate? It's basically a UNION, something like shown below but I am not sure how to do the domain models in C# and mappings of NHibernate.
I basically have 1 abstract class and 2 concrete classes. Each concrete class can be mapped to a single table in the databse....
I have the below SQLITE code
SELECT x.t,
CASE WHEN S.Status='A' AND M.Nomorebets=0 THEN S.PriceText ELSE '-' END AS Show_Price
FROM sb_Market M
LEFT OUTER JOIN
(select 2010 t union
select 2020 t union
select 2030 t union
select 2040 t union
select 2050 t union
select 2060 t union
select 2070 t
) as x
LEFT OUTER JOIN sb_Selection S ON
S....
I want to learn how to combine two db tables which have no fields in common. I've checked UNION but MSDN says :
The following are basic rules for combining the result sets of two queries by using UNION:
The number and the order of the columns must be the same in all queries.
The data types must be compatible.
But I hav...
I had a working FREETEXTTABLE query that searched for a @searchString. I now need to UNION that with another simple query that tries to parse the @searchString into an INT, and if it succeeds, filtering the table by looking for the row with PK equal to the parse @searchString.
Previously, I could easily JOIN the FREETEXTTABLE result to ...
I recently discovered that something compiles(not sure that it's legal though). My need for such a thing comes from this: My project outputs machine code for a selected arch.(which may or may not be the same arch. as the one running the program). So, I would like to support up to 64bit architectures right now(while also supporting existi...
I've got two content types, both have a node title and a document attachment, the doc attachment fields are different names (being from two different content types).
In my view, I'm displaying the node title and the file name in a table. The node titles are great all in one column, but the two content typed attachment fields are display...
I've got a union :
union my_union
{ short int Int16; float Float; };
I'd like to create :
const my_union u1 = ???;
const my_union u2 = ???;
and initialize their values to be of different types respectively :
u1 -> int16
u2 -> float
How do I do that ? If the above is not possible, are there any workarounds?
...
I have a method that gets a number of objects of this class
class Range<T>
{
public T Start;
public T End;
}
In my case T is DateTime, but lets use int for simplicity. I would like a method that collapses those ranges into ones that cover the same "area" but that do not overlap.
So if I had the following ranges
1 to 5
3 to ...
Just read on an internal university thread:
#include <iostream>
using namespace std;
union zt
{
bool b;
int i;
};
int main()
{
zt w;
bool a,b;
a=1;
b=2;
cerr<<(bool)2<<static_cast<bool>(2)<<endl; //11
cerr<<a<<b<<(a==b)<<endl; //111
w.i=2;
int q=w.b;
cerr<<(bool)q<<...
Hi.
I have three tables with the following structure:
tb1: id(AI, PK), uid, date, text
tb2: id(AI, PK), uid, date, text ... and so on
I have to keep them separate because of additional unqiue data that each table has.
I'd like to execute a query that will merge and get me the last 20 entries (ie, date DESC) (specifically, i need uid a...
Hi all,
we have a DB which stores users who may have pictures.
I am looking for an elegant way in SQL to get the following results:
Select n users. Of those n users e.g. 60% should have an associated picture and 40% should not have a picture. If there are less than 60% users having a picture the result should be filled up with users wi...
Hi.
I have three tables, each contain some common information, and some information that is unique to the table.
For example: uid, date are universal among the tables, but one table can contain a column type while the other contains currency.
I need to query the database and get the last 20 entries (date DESC) that have been entered in ...
Hello
I have a SQL query, looks something like this:
select name, count (*) from Results group by name order by name
and another, identical which loads from a archive results table, but the fields are the same.
select name, count (*) from Archive_Results group by name order by name
How would I combine the two in just one query? (S...
Hi gurus,
This question explained about a way of getting distinct combination of multiple columns. But I want to know the difference between the methods of DISTINCT, UNION, GROUP BY keyword method for this purpose. I am getting different results when using them.
My queries are like this
Query 1.
select
column1,
column2,
column3
from ta...
I have a table of employees and their schedule, like so:
Emp_Name | Date
-------- -----
Smith | 08-01-2009
Jones | 08-01-2009
Goodman | 08-02-2009
Smith | 08-02-2009
Jones | 08-02-2009
Goodman | 08-03-2009
How would I write a query so that the results were only employee names of employees working on 08-02-2009 and 08-03...
I have to admit in all my work with Java, I've never come across the need for a Java union (like the C union, not the SQL one) and I cannot find an answer here on SO. Admittedly, most of my work in Java has been at higher abstractions that bit-fiddling.
I have a integer which I'm setting individual bits for and I want to print out the e...
Hi all.
I need to get the row count for individual SELECT statements in an UNION ALL SELECT query that uses LIMIT. The MySQL docs are pretty clear about getting the global row count for the query (place individual SELECTs in parenthesis and place an SQL_CALC_FOUND_ROWS only in the first statement, then get FOUND_ROWS() the usual way). Ho...
I'm pretty sure this is not possible in Zend Framework (I have searched the Web, the documentation and issue tracker) but I just want to make sure so I'm asking here.
$select = $this->select();
$select->union($select1, $select2);
That doesn't work of course. To explain what I need. I need to use UNION() to merge 2 tables in a SELECT q...