Mysql 5.1 union with group by for results

2013-11-08 Thread Machiel Richards
JOIN client2 c ON t.ClientID=c.ID LEFT JOIN tocname tc ON t.TOC=tc.toc LEFT JOIN network n ON t.NetworkID=n.ID WHERE t.toc=1 AND SUBSTRING(t.Day,1,7) = '2013-08' AND SUBSTRING(t.Day,1,7) = '2013-11') UNION (SELECT SUBSTRING(t.Day,1,7) AS Date, a.Name AS Account

Re: Mysql 5.1 union with group by for results

2013-11-08 Thread Jesper Wisborg Krogh
a shorter but equivalent query, you have: (SELECT t.id, t.name, SUM(val) FROM t1 t) UNION (SELECT t.id, t.name, SUM(val) FROM t2 t) GROUP BY t.id, t.name; That does not work in 5.0 either (at least in 5.0.96): ERROR 1064 (42000): You have an error in your SQL syntax; check

Re: Mysql 5.1 union with group by for results

2013-11-08 Thread Johan De Meersman
been doing what you think at all, and you need to select [fields] from ( select fields1 blahblah UNION select fields2 blahblah) unionized group by blurb that is, wrap the entire union in a virtual table and do the group by on that. -- Unhappiness is discouraged

Re: Mysql 5.1 union with group by for results

2013-11-08 Thread Machiel Richards
UNION select fields2 blahblah) unionized group by blurb that is, wrap the entire union in a virtual table and do the group by on that. -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe:http://lists.mysql.com/mysql

Re: Mysql 5.1 union with group by for results

2013-11-08 Thread Machiel Richards
) FROM t1 t) UNION (SELECT t.id, t.name, SUM(val) FROM t2 t) GROUP BY t.id, t.name; That does not work in 5.0 either (at least in 5.0.96): ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax

UNION and ORDER BY

2012-06-21 Thread Hal�sz S�ndor
2012/06/20 14:32 -0700, Rick James ( SELECT ruid1, ruid2, overlap FROM l4_link WHERE ruid1=xxx UNION SELECT ruid1, ruid2, overlap FROM l4_link WHERE ruid2=xxx ) ORDER BY overlap DESC; Make it UNION ALL or UNION DISTINCT depending on whether xxx can be in both fields of one row. UNION

RE: UNION and ORDER BY

2012-06-21 Thread Rick James
BY with just the second SELECT. -Original Message- From: Hal?sz S?ndor [mailto:h...@tbbs.net] Sent: Thursday, June 21, 2012 4:07 PM To: mysql@lists.mysql.com Subject: UNION and ORDER BY 2012/06/20 14:32 -0700, Rick James ( SELECT ruid1, ruid2, overlap FROM l4_link WHERE ruid1=xxx

query mystery: union de-optimizes component queries

2011-08-26 Thread Dave Dyer
Why would using UNION cause the subqueries to be de-optimized? explain (SELECT count(gamename) as gname ,variation from zertz_gamerecord where (gmtdate date_sub(current_timestamp(),interval 90 day)) and (player1='13213' or player2='13213' ) group by variation limit 3) shows using index

MERGE Engine vs. UNION ALL

2011-04-07 Thread James W. McKelvey
We've been experimenting with the merge engine. But suppose that instead of using the MERGE engine I instead modified my code to UNION ALL the shards. Would I get worse performance? In other words, besides the convenience, does the MERGE engine have specific performance optimizations

Slow Union Statement

2010-04-05 Thread chen jia
Hi there, I run simple statement like this: create table c select * from a union select * from b; where table a has 90,402,534 rows, and table b has 33,358,725 rows. Both tables have the same three variables. It's taken a long time, more than half an hour now. How do I make it faster? Best

Re: Slow Union Statement

2010-04-05 Thread Rudy Lippan
On 04/05/2010 02:06 PM, chen jia wrote: Hi there, I run simple statement like this: create table c select * from a union select * from b; where table a has 90,402,534 rows, and table b has 33,358,725 rows. Both tables have the same three variables. It's taken a long time, more

RE: Slow Union Statement

2010-04-05 Thread Gavin Towey
Union does a distinct on all results. UNION ALL will avoid that. Regards, Gavin Towey -Original Message- From: chen.1...@gmail.com [mailto:chen.1...@gmail.com] On Behalf Of chen jia Sent: Monday, April 05, 2010 11:07 AM To: mysql@lists.mysql.com Subject: Slow Union Statement Hi

Re: Slow Union Statement

2010-04-05 Thread chen jia
Yes, that's the trick. Thank Rudy and Gavin. Best, Jia On Mon, Apr 5, 2010 at 2:13 PM, Gavin Towey gto...@ffn.com wrote: Union does a distinct on all results.  UNION ALL will avoid that. Regards, Gavin Towey -Original Message- From: chen.1...@gmail.com [mailto:chen.1...@gmail.com

Creating Table Through Union

2009-11-22 Thread Victor Subervi
Hi; I would like to create a table out of merging the fields in other, previously created tables. I have the following syntax which doesn't work: create table products union (b0basics, b0fieldValues, s0prescriptions, s0prescriptions0doctors, s0prescriptions0patient, pics); Please advise. TIA

RE: Creating Table Through Union

2009-11-22 Thread Gavin Towey
The form would be like: CREATE TABLE products SELECT b0basics, b0fieldValues, s0prescriptions, s0prescriptions0doctors, s0prescriptions0patient, pics FROM table1 UNION SELECT b0basics, b0fieldValues, s0prescriptions, s0prescriptions0doctors, s0prescriptions0patient, pics FROM table2 Regards

Re: Creating Table Through Union

2009-11-22 Thread Victor Subervi
On Sun, Nov 22, 2009 at 9:29 PM, Gavin Towey gto...@ffn.com wrote: The form would be like: CREATE TABLE products SELECT b0basics, b0fieldValues, s0prescriptions, s0prescriptions0doctors, s0prescriptions0patient, pics FROM table1 UNION SELECT b0basics, b0fieldValues, s0prescriptions

OR vs UNION

2009-10-13 Thread Majk.Skoric
| index_merge | buchungs_kunde_id,kunde_id | buchungs_kunde_id,kunde_id | 71,71 | NULL |2 | Using union(buchungs_kunde_id,kunde_id); Using where

Re: OR vs UNION

2009-10-13 Thread Joerg Bruehe
| ++-+---+-++- ---+-+--+--+ --+ | 1 | SIMPLE | KTEMP | index_merge | buchungs_kunde_id,kunde_id | buchungs_kunde_id,kunde_id | 71,71 | NULL |2 | Using union(buchungs_kunde_id,kunde_id); Using where

AW: OR vs UNION

2009-10-13 Thread Majk.Skoric
-Ursprüngliche Nachricht- Von: joerg.bru...@sun.com [mailto:joerg.bru...@sun.com] Gesendet: Dienstag, 13. Oktober 2009 15:26 An: Skoric, Majk Cc: mysql@lists.mysql.com Betreff: Re: OR vs UNION Majk, all, I'm no optimizer expert, but your result doesn't really surprise me

Union query

2008-04-29 Thread kabel
) representing a user's answer to a survey. I'm trying to determine how many surveys per show responded with response_id 30 and response_id 28 I think I need a union here, but am not sure. So far, I THINK I can figure out how many surveys per show responded with just response 30 as follows: SELECT

RE: union operator problems in MySQL v3.23?

2008-01-14 Thread Lopez David E
glenn Union is 4.0 feature. david Notwithstanding end-of-life status, is there an issue in MySQL v3.23 r.e. the union operator? -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]

union operator problems in MySQL v3.23?

2008-01-11 Thread Glenn Gillis
Notwithstanding end-of-life status, is there an issue in MySQL v3.23 r.e. the union operator? My installation returns a syntax error on any query containing the union operator, even with the sample queries provided in the documentation: mysql SELECT REPEAT('a',1) UNION SELECT REPEAT('b',10

Re: union operator problems in MySQL v3.23?

2008-01-11 Thread Jim Winstead
On Fri, Jan 11, 2008 at 12:28:05PM -0800, Glenn Gillis wrote: Notwithstanding end-of-life status, is there an issue in MySQL v3.23 r.e. the union operator? My installation returns a syntax error on any query containing the union operator, even with the sample queries provided

Re: union operator problems in MySQL v3.23?

2008-01-11 Thread Glenn Gillis
Jim Winstead wrote, On 1/11/2008 12:54 PM: On Fri, Jan 11, 2008 at 12:28:05PM -0800, Glenn Gillis wrote: Notwithstanding end-of-life status, is there an issue in MySQL v3.23 r.e. the union operator? My installation returns a syntax error on any query containing the union operator, even

BUG in UNION implementation?! Confimation or Explaination please

2007-07-11 Thread list account
Hi all, I believe to have found a bug in MySQL's union implementation. Can someone confirm this, please or convince me that this is not a buggy behaviour of mysql : UNION seems to behave like DISTINCT by default: mysql select 2 c1 - union - select 1 c1 - union - select 2 c1

Re: BUG in UNION implementation?! Confimation or Explaination please

2007-07-11 Thread Anders Karlsson
UNION will only return distinct rows. This is according to spec and to the SQL Standard. To avoid this, use UNION ALL instead of UNION. Try that with your queries and you'll see that this will do the trick. This is, as I said, in accordance with the standard and the way all SQL based databases

RE: BUG in UNION implementation?! Confimation or Explaination please

2007-07-11 Thread Rhys Campbell
UNION is mean to removed duplicate rows. Use UNION ALL if you don't want this to happen. http://dev.mysql.com/doc/refman/5.0/en/union.html -Original Message- From: list account [mailto:[EMAIL PROTECTED] Sent: 11 July 2007 09:19 To: mysql@lists.mysql.com Subject: BUG in UNION

Re: BUG in UNION implementation?! Confimation or Explaination please

2007-07-11 Thread Joshua J. Kugler
On Wednesday 11 July 2007 00:34, Anders Karlsson wrote: UNION will only return distinct rows. This is according to spec and to the SQL Standard. And of course, to no one's surprise, this also matches the mathematical definition of union: j -- Joshua Kugler Lead

FOUND_ROWS UNION

2006-07-04 Thread Taras D
Hi everyone, I have a couple of questions invovling using FOUND_ROWS() and UNION. The manual states that: The value of FOUND_ROWS() is exact only if UNION ALL is used. If UNION without ALL is used, duplicate removal occurs and the value of FOUND_ROWS() is only approximate. I am using UNION

RE: Query problem: UNION in subquery

2006-05-24 Thread Neeraj
Hi Luke.. Try this SELECT ObjectId FROM (SELECT f15.Form15SampleTube1RnaBarcode AS ObjectId, f15.Form15PatientID AS PtId FROM form15 f15 WHERE f15.Form15SampleTube1RnaBarcode IN ('01D2V','01DH6') UNION SELECT f15.Form15SampleTube6RnaBarcode AS ObjectId, f15.Form15PatientID AS PtId

Re: Query problem: UNION in subquery

2006-05-24 Thread Luke
A big Thank you goes to you! That was it! Looks like I tried with too many parentheses i.e. /this is wrong/ SELECT FROM ... ( (SELECT FROM ...) UNION (SELECT FROM ...) ) AS abc Regards, Luke - Original Message - From: Neeraj [EMAIL PROTECTED] To: 'Luke' [EMAIL PROTECTED

Query problem: UNION in subquery

2006-05-23 Thread Luke
Hello! I have a problem using UNIONs inside subqueries. I have simplified my query to make it more readable/understandable. The question is about the right syntax. 1. This works fine /UNION/ (SELECT f15.Form15SampleTube1RnaBarcode AS ObjectId, f15.Form15PatientID AS PtId FROM form15

Re: Select Sum with union, tricky question perhaps not for you

2006-04-04 Thread SGreen
H L [EMAIL PROTECTED] wrote on 04/03/2006 01:53:37 PM: The solution is to redesign your tables. You need to split into separate columns the values you want to maintain. You do not want to keep the flat file design you are currently trying to use. CREATE TABLE calendar ( objectid,

Re: Select Sum with union, tricky question perhaps not for you

2006-04-03 Thread H L
The solution is to redesign your tables. You need to split into separate columns the values you want to maintain. You do not want to keep the flat file design you are currently trying to use. CREATE TABLE calendar ( objectid, year, dayofyear, ... other fields... ) CREATE TABLE price (

Select Sum with union, tricky question perhaps not for you

2006-04-02 Thread H L
Hi, i have a problem to select sum from same table using UNION. The key question is there a way of combining two questions in one so the resulting objectid in query1 is only used in query 2 in a smart way. Eg. if only one object is avaliable in a search first year then only check

Re: Select Sum with union, tricky question perhaps not for you

2006-04-02 Thread SGreen
H L [EMAIL PROTECTED] wrote on 04/02/2006 11:51:48 AM: Hi, i have a problem to select sum from same table using UNION. The key question is there a way of combining two questions in one so the resulting objectid in query1 is only used in query 2 in a smart way. Eg. if only one object

Problem with UNION

2006-03-01 Thread Shaun
Hi, The following 3 queries on their own produce more rows than if I UNION them together: SELECT CONCAT('Y',DATE_FORMAT(Date,'%Y')) AS Booking_Year, CONCAT('M',DATE_FORMAT(Date,'%c')) AS Booking_Month, CONCAT('USR_', B.User_ID) AS User, Booking_Status, CONCAT('W_', Work_Type_ID) AS Day_Type, '1

Re: Problem with UNION

2006-03-01 Thread Gabriel PREDA
The UNION Syntax is: SELECT ... UNION [ALL | DISTINCT] SELECT ... [UNION [ALL | DISTINCT] SELECT ...] Lower in the manual it says: * A DISTINCT union can be produced explicitly by using UNION DISTINCT or implicitly by using UNION with no following DISTINCT or ALLkeyword. * ** So

Re: Problem with UNION

2006-03-01 Thread Rhino
Shaun [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] Hi, The following 3 queries on their own produce more rows than if I UNION them together: SELECT CONCAT('Y',DATE_FORMAT(Date,'%Y')) AS Booking_Year, CONCAT('M',DATE_FORMAT(Date,'%c')) AS Booking_Month, CONCAT('USR_', B.User_ID

5.0.16. Bug in union?

2006-02-14 Thread Juri Shimon
Hello mysql, Union on zerofilled fields eats 'zerofilling'. How to repeat: create table a (id integer zerofill); insert into a values(1),(2),(3); select * from a; ++ | id | ++ | 01 | | 02 | | 03 | ++ select * from

Re: 5.0.16. Bug in union?

2006-02-14 Thread Gabriel PREDA
Interesting... maybe this is because the fill is not actualy stored in the database... and being sorted/compared as a number MySQL removes the ZEROFILL ! You can go and do: select BINARY * from a union select BINARY * from a; -- Gabriel PREDA Senior Web Developer On 2/14/06, Juri Shimon [EMAIL

Re: union/collation problem, error 1267: feature or bug?

2006-01-28 Thread schlubediwup
Hi Gleb, i finally found out a method to be entirely independent from any character-set as well as collation-sequence problem, when forming a UNION, where you occasionnally have to insert place-holders in one of the SELECT statements: as (text, varchar, char) placeholders use NULL instead

Re: union/collation problem, error 1267: feature or bug?

2006-01-25 Thread schlubediwup
Hi Gleb, localhost.(none) show session variables like %version%; +-+--+ | Variable_name | Value| +-+--+ |

Re: union/collation problem, error 1267: feature or bug?

2006-01-21 Thread Gleb Paharenko
| +--+---+ 3 rows in set (0.00 sec) localhost.addresses2 4. following problem: when i do a union statement between the two tables, where obviousely at least in one select of the union some fields are left open by the placeholder or '' , these left-off fields are acted

is UNION allowed in a MySQL stored procedure?

2006-01-19 Thread Gordon Bruce
I have a simple stored procedure which works as intended. As soon as I add a UNION in the SELECT I get the error message ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'select phon_Lvl

union/collation problem, error 1267: feature or bug?

2006-01-19 Thread schlubediwup
| latin1_swedish_ci | | collation_server | latin1_swedish_ci | +--+---+ 3 rows in set (0.00 sec) localhost.addresses2 4. following problem: when i do a union statement between the two tables, where obviousely at least in one select of the union some

Insert into table select * ... union

2006-01-14 Thread Detlev Jaeger
sending 50 insert into summarytable select * from table-xx on duplicate key update commands. After explaining my details, I would like to know, if there is a possibility of a command like insert into summarytable select * from `table-01` union select * from `table-02` union select * from `table

About union sql Mysql 4.x

2005-12-05 Thread HALIL DEMIREZEN
Hi, I am trying to run an sql query such as below to list items=x randomly and then items != x randomly.. mysql (select * from tablea where item=1 order by rand()) union all (select * from tablea where item != 1 order by rand()); but the result is not as expected. rand() seems

Re: About union sql Mysql 4.x

2005-12-05 Thread Gleb Paharenko
for your query. HALIL DEMIREZEN wrote: Hi, I am trying to run an sql query such as below to list items=x randomly and then items != x randomly.. mysql (select * from tablea where item=1 order by rand()) union all (select * from tablea where item != 1 order by rand

Re: About union sql Mysql 4.x

2005-12-05 Thread HALIL DEMIREZEN
] --- Gleb Paharenko [EMAIL PROTECTED] 05.12.2005 12:19 To mysql@lists.mysql.com cc Subject Re: About union sql Mysql 4.x Hello. From http://dev.mysql.com/doc/refman/5.0/en/union.html: ORDER BY for individual SELECT statements within parentheses

Re: About union sql Mysql 4.x

2005-12-05 Thread Michael Stassen
HALIL DEMIREZEN wrote: Hi, I am trying to run an sql query such as below to list items=x randomly and then items != x randomly.. mysql (select * from tablea where item=1 order by rand()) union all (select * from tablea where item != 1 order by rand()); but the result is not as expected

Re: About union sql Mysql 4.x

2005-12-05 Thread HALIL DEMIREZEN
Michael, Thank you and all for effort to help.. I solved the problem by giving high limit numbers such as; (select * from tablea where item=1 order by rand() limit 0, 1) union all (select * from tablea where item != 1 order by rand() limit 0, 1

Re: About union sql Mysql 4.x

2005-12-05 Thread Gleb Paharenko
[EMAIL PROTECTED] 05.12.2005 12:19 To mysql@lists.mysql.com cc Subject Re: About union sql Mysql 4.x Hello. From http://dev.mysql.com/doc/refman/5.0/en/union.html: ORDER BY for individual SELECT statements within parentheses has

Re: About union sql Mysql 4.x

2005-12-05 Thread Michael Stassen
HALIL DEMIREZEN wrote: Michael, Thank you and all for effort to help.. I solved the problem by giving high limit numbers such as; (select * from tablea where item=1 order by rand() limit 0, 1) union all (select * from tablea where item != 1 order by rand() limit 0, 1

Does MySQL 3.23.58 Support UNION

2005-10-28 Thread Simon Longstaff
I'm trying to run this : SELECT DISTINCT A.B_IP FROM w3t_Posts A , w3t_Users B WHERE A.B_PosterID = B.U_Number and B.U_Username = 'user1' UNION SELECT DISTINCT C.B_IP FROM w3t_Posts C , w3t_Users D WHERE C.B_PosterID = D.U_Number and D.U_Username = 'user2' and it's failing saying SQL Error

Re: Does MySQL 3.23.58 Support UNION

2005-10-28 Thread SGreen
Simon Longstaff [EMAIL PROTECTED] wrote on 10/28/2005 10:50:24 AM: I'm trying to run this : SELECT DISTINCT A.B_IP FROM w3t_Posts A , w3t_Users B WHERE A.B_PosterID = B.U_Number and B.U_Username = 'user1' UNION SELECT DISTINCT C.B_IP FROM w3t_Posts C , w3t_Users D WHERE C.B_PosterID

Re: MySQL error 1267: Illegal mix of collations (latin1_swedish_ci,COERCIBLE) and (utf8_general_ci,IMPLICIT) for operation 'UNION' -- again

2005-10-21 Thread Gleb Paharenko
Hello. MySQL error 1267: Illegal mix of collations (latin1_swedish_ci,COERCIBLE) and (utf8_general_ci,IMPLICIT) for operation 'UNION' -- again Check the character set of fields in you tables with 'SHOW CREATE TABLE' statement. I recommend you to test if the problem remains in 4.1.14

MySQL error 1267: Illegal mix of collations (latin1_swedish_ci,COERCIBLE) and (utf8_general_ci,IMPLICIT) for operation 'UNION' -- again

2005-10-19 Thread Jeff Kolber
Hi list, I've got a query coming out of sugarCRM that is generating this error: MySQL error 1267: Illegal mix of collations (latin1_swedish_ci,COERCIBLE) and (utf8_general_ci,IMPLICIT) for operation 'UNION' I recently converted the entire database to utf8 - made sure all the connections

Union vs OR

2005-08-26 Thread avrombay
I have a table that holds attributes for users. This is the structure: TABLE properties ( id int(11) NOT NULL, userid int(11) NOT NULL, attrType int(11) NOT NULL, attrValue text NOT NULL, FULLTEXT KEY propValue (propValue) ) TYPE=MyISAM; The table is used to find people based on

RE: Union vs OR

2005-08-26 Thread Gordon Bruce
It's getting late on Friday, but couldn't you build a table with all of the parameter combinations and then just join against that table? -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Sent: Friday, August 26, 2005 4:25 PM To: mysql@lists.mysql.com Subject: Union vs

RE: Union vs OR

2005-08-26 Thread SGreen
: Friday, August 26, 2005 4:25 PM To: mysql@lists.mysql.com Subject: Union vs OR I have a table that holds attributes for users. This is the structure: TABLE properties ( id int(11) NOT NULL, userid int(11) NOT NULL, attrType int(11) NOT NULL, attrValue text NOT NULL, FULLTEXT KEY

Re: Illegal mix of collations (latin1_swedish_ci,COERCIBLE) and (utf8_general_ci,IMPLICIT) for operation 'UNION'

2005-08-25 Thread Gleb Paharenko
Hello. What is the value of the default_charset variable in your php.ini file? What version of MySQL do you use? Florian Burkart [EMAIL PROTECTED] wrote: What might help as well is another problem I have: Somehow, the data I am getting out of mysql and php and is being served by

Re: Illegal mix of collations (latin1_swedish_ci,COERCIBLE) and (utf8_general_ci,IMPLICIT) for operation 'UNION'

2005-08-25 Thread Florian Burkart
Hey Gleb, thanks for taking your time! php.ini: ; As of 4.0b4, PHP always outputs a character encoding by default in ; the Content-type: header. To disable sending of the charset, simply ; set it to be empty. ; ; PHP's built-in default is text/html default_mimetype = text/html

Illegal mix of collations (latin1_swedish_ci,COERCIBLE) and (utf8_general_ci,IMPLICIT) for operation 'UNION'

2005-08-24 Thread Florian Burkart
Hey everyone, can't figure this one out, might be easy for one of you. This is the query: (SELECT 'Neue Gruppe' AS gruppenstring, '-1' AS gruppe_id) UNION ALL (SELECT CONCAT( gruppe, ' (', kommentar, ')' ) AS gruppenstring, gruppe_id FROM tbl_gruppen ORDER BY gruppe); This error message

Illegal mix of collations (latin1_swedish_ci,COERCIBLE) and (utf8_general_ci,IMPLICIT) for operation 'UNION'

2005-08-24 Thread Florian Burkart
Hey everyone, can't figure this one out, might be easy for one of you. This is the query: (SELECT 'Neue Gruppe' AS gruppenstring, '-1' AS gruppe_id) UNION ALL (SELECT CONCAT( gruppe, ' (', kommentar, ')' ) AS gruppenstring, gruppe_id FROM tbl_gruppen ORDER BY gruppe); This error message

Re: Illegal mix of collations (latin1_swedish_ci,COERCIBLE) and (utf8_general_ci,IMPLICIT) for operation 'UNION'

2005-08-24 Thread Gleb Paharenko
. This is the query: (SELECT 'Neue Gruppe' AS gruppenstring, '-1' AS gruppe_id) UNION ALL (SELECT CONCAT( gruppe, ' (', kommentar, ')' ) AS gruppenstring, gruppe_id FROM tbl_gruppen ORDER BY gruppe); This error message is returned on the php website: Illegal mix of collations

Re: Illegal mix of collations (latin1_swedish_ci,COERCIBLE) and (utf8_general_ci,IMPLICIT) for operation 'UNION'

2005-08-24 Thread Florian Burkart
] wrote: Hey everyone, can't figure this one out, might be easy for one of you. This is the query: (SELECT 'Neue Gruppe' AS gruppenstring, '-1' AS gruppe_id) UNION ALL (SELECT CONCAT( gruppe, ' (', kommentar, ')' ) AS gruppenstring, gruppe_id FROM tbl_gruppen ORDER

Re: Illegal mix of collations (latin1_swedish_ci,COERCIBLE) and (utf8_general_ci,IMPLICIT) for operation 'UNION'

2005-08-24 Thread Florian Burkart
CREATE TABLE tbl_gruppen; Florian Burkart [EMAIL PROTECTED] wrote: Hey everyone, can't figure this one out, might be easy for one of you. This is the query: (SELECT 'Neue Gruppe' AS gruppenstring, '-1' AS gruppe_id) UNION ALL (SELECT CONCAT( gruppe, ' (', kommentar

UNION - different result when statements interchanged

2005-08-05 Thread Kapoor, Nishikant
I have a UNION whose statements when interchanged gives a different result. I can understand the change in the order of the rows, but how is it that 'picture' gets the correct value in (a) but not in (b)? Here are the two queries and their results: (a) (SELECT u.lName last_name, u.picture

Re: UNION - different result when statements interchanged

2005-08-05 Thread Scott Noyes
From http://dev.mysql.com/doc/mysql/en/union.html : Before MySQL 4.1.1, a limitation of UNION is that only the values from the first SELECT are used to determine result column types and lengths. This could result in value truncation if, for example, the first SELECT retrieves shorter values than

RE: Speeding UNION with merging indexes

2005-08-03 Thread Eli Hen
`a` (`a`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1 1 row in set (0.00 sec) mysql EXPLAIN (SELECT * FROM t1 WHERE a='a') UNION (SELECT * FROM t2 WHERE a='a') ORDER BY id LIMIT 0,5 \G *** 1. row *** id: 1 select_type: PRIMARY table: t1

RE: Speeding UNION with merging indexes

2005-08-03 Thread SGreen
I am not sure about index merging but you should be able to speed things up if you ORDER BY and LIMIT your inner queries as well: (SELECT * FROM t1 WHERE a='a' ORDER BY id limit 0,5) UNION (SELECT * FROM t2 WHERE a='a' ORDER BY id limit 0,5) ORDER BY id LIMIT 0,5 To answer your UNION query

Re: Speeding UNION with merging indexes

2005-08-03 Thread Eli Hen
:-) [EMAIL PROTECTED] wrote: I am not sure about index merging but you should be able to speed things up if you ORDER BY and LIMIT your inner queries as well: (SELECT * FROM t1 WHERE a='a' ORDER BY id limit 0,5) UNION (SELECT * FROM t2 WHERE a='a' ORDER BY id limit 0,5) ORDER BY id LIMIT 0,5

Re: Speeding UNION with merging indexes

2005-08-02 Thread Gleb Paharenko
Hello. MySQL uses indexes in queries which are parts of UNION. See: mysql explain (select * from t1 where a=5) union (select * from t1 where a=3)\G; *** 1. row *** id: 1 select_type: PRIMARY table: t1 type

Speeding UNION with merging indexes

2005-08-01 Thread Eli Hen
Hello, MySQL implemented index_merge in version 5... Does MySQL supports something like index_merge to speed up UNION queries? If yes, for which version (assumed release time)? Does anyone know of other DBs systems that can speed up UNION queries? This issue is quite critical for our system

Re: UNION in JDBC - WAS Re: use of indexes

2005-07-27 Thread Gleb Paharenko
Hello. Check with SHOW PROCESSLIST in which state MySQL thread which performs the query is. See: http://dev.mysql.com/doc/mysql/en/show-processlist.html Chris Faulkner [EMAIL PROTECTED] wrote: Hello again Following on from this index question, the UNION worked. From a normal

UNION in JDBC - WAS Re: use of indexes

2005-07-24 Thread Chris Faulkner
Hello again Following on from this index question, the UNION worked. From a normal mysql client, it was returning my results sub-second. I am actually executing this over JDBC, using mysql-connector j. WHen I put the SQL into my Java program - it takes a minute or so. I am logging the SQL

Re: Performance difference? : [SELECT ON Merge TableAB] vs [(SELECT ON Table A) UNION (SELECT ON TABLE B) ]

2005-07-18 Thread Gleb Paharenko
Hello. I've searched in the archives at: http://lists.mysql.com/mysql but the only thing I've found is that the speed difference is rather low. In my opinion, using UNION is a more flexible solution. pow [EMAIL PROTECTED] wrote: Hi everyone, Take for example two identical

Performance difference? : [SELECT ON Merge TableAB] vs [(SELECT ON Table A) UNION (SELECT ON TABLE B) ]

2005-07-17 Thread pow
Hi everyone, Take for example two identical tables A B, and a MERGE table merging both of them. Would there be any performance advantage if I do a select (with a where criteria on an indexed column) on the MERGE table, as opposed to doing a union of two selects with the same WHERE criteria

VARCHAR changes to INT - UNION

2005-07-15 Thread Dennis Duggen
` , `text` ); INSERT INTO searchTemp ( SELECT 'content', id, headline, text, teaser, image_id FROM content ) UNION ALL ( SELECT 'wesHoldKategori', wesHoldKategori.Kode AS id, Navn AS headline, Beskrivelse AS text, '', image_id FROM wesHoldKategori

Re: VARCHAR changes to INT - UNION

2005-07-15 Thread Eugene Kosov
Dennis Duggen wrote: Hi list Im new to the list so i hope it's the right place for my post. For a projekt i am combining different tables. Everything seems to work, but in some rows the Kode field VARCHAR(10) ends up as INT. I will try to explain with an example. Table1 46 47 48 67 Table2

Re: VARCHAR changes to INT - UNION

2005-07-15 Thread Michael Stassen
' results should have the same type. Try to cnage order of SELECTs in your query.. I think you'll get what you want. Right, the type of each column is determined by the first SELECT in the UNION. Hence, your VARCHARs are converted to INTs because they are in an INT column based on the first SELECT

Why would a UNION be 100x slower than the same SELECT...

2005-06-27 Thread Kevin Burton
Here's a big problem I'm having. If I have a query like: SELECT * FROM FOO WHERE FOO.LAST_UPDATED 1119898418779 AND FOO.FEED_ID = 1 ORDER BY FOO.LAST_UPDATED DESC LIMIT 10 it only takes about 10ms or so to execute. but... if I rewrite it to wrap it in a union like so: ( SELECT * FROM FOO

Re: Why would a UNION be 100x slower than the same SELECT...

2005-06-27 Thread Kevin Burton
SQL expression is evaluated which is then given to the union. Evil I say! Pure evil! I was able to figure this out because Handler_read_next was being incremented to the same value as the total number of rows in this expression. Cool now at least I know why its screwing up. Kevin

Re: Why would a UNION be 100x slower than the same SELECT...

2005-06-27 Thread Rhino
Why do you think you're using a UNION in your query? The keyword UNION doesn't appear anywhere in your query. You don't even have a second query being UNIONed to the first. All you've got is a pair of parentheses surrounding your original query, which seems to perform okay. For what it's worth, I

Re: Why would a UNION be 100x slower than the same SELECT...

2005-06-27 Thread Kevin Burton
Kevin Burton wrote: Any idea whats going on and how I could fix this? This seems like a bug in the SQL parser. The LIMIT is only ignored in this one situation. If I just add a: UNION (SELECT * FROM FOO LIMIT 0) To the query will work correctly. This might be an acceptable workaround

Re: mysql UNION

2005-06-06 Thread mfatene
as selected, type from news where [EMAIL PROTECTED] - union select id,@cat2 as selected, type from faq where [EMAIL PROTECTED] - union select id,@cat3 as selected, type from forum where [EMAIL PROTECTED]; +--+--+---+ | id | selected | type

Re: mysql UNION

2005-06-06 Thread mfatene
query. The only condition is to add a where clause a the column type which will retreive empty set for the non selected conditions. Example :! set @cat1:='news'; set @cat2:='faq'; set @cat3:='forum'; mysql select id,@cat1 as selected, type from news where [EMAIL PROTECTED] - union select

Re: mysql UNION

2005-06-05 Thread mfatene
The second method is dynamic sql with prepare statement from string. It's better for the reason that the query is generated to retrieve data from just one table (not an union which implies 3 tables). The day your tables will be huge, i'm sure you will use the second method. two crazy people can

Re: mysql UNION

2005-06-05 Thread Michael Stassen
Sebastian wrote: Michael Stassen wrote: Sebastian wrote: i have a query with 3 union selects: SELECT id, 'news' AS type, FROM news UNION SELECT id, 'faq' AS type, FROM faq UNION SELECT id, 'forum' AS type, FROM forum which works just fine and selects

Re: mysql UNION

2005-06-05 Thread mfatene
, and other rdbms. P.S. haven't spent days to help. It is easy. And since it was a week-end :o) Mathias Selon Michael Stassen [EMAIL PROTECTED]: Sebastian wrote: Michael Stassen wrote: Sebastian wrote: i have a query with 3 union selects: SELECT id, 'news' AS type, FROM

Re: mysql UNION

2005-06-05 Thread Sebastian
Michael Stassen wrote: Sebastian wrote: Michael Stassen wrote: Sebastian wrote: i have a query with 3 union selects: SELECT id, 'news' AS type, FROM news UNION SELECT id, 'faq' AS type, FROM faq UNION SELECT id, 'forum' AS type, FROM forum which

Re: mysql UNION

2005-06-05 Thread Michael Stassen
[EMAIL PROTECTED] wrote: Hi Sebastian; There is always crazy things somewhere. I'll give you two methods for that : mysql select id,'news' as selected, type from news - union select id,'faq' as selected, type from faq - union select id,'forum' as selected, type from forum

Re: mysql UNION

2005-06-05 Thread Michael Stassen
[EMAIL PROTECTED] wrote: I agree with you, just see that if .. sql = SELECT id, '$cat' AS type, ... FROM $cat; is exactly what is done in prepare statement. Yes, I acknowledged that in my next message (a reply to yours). dynamic sql is better than application level statement preparation,

Re: mysql UNION

2005-06-05 Thread Sebastian
Michael Stassen wrote: [EMAIL PROTECTED] wrote: Hi Sebastian; There is always crazy things somewhere. I'll give you two methods for that : mysql select id,'news' as selected, type from news - union select id,'faq' as selected, type from faq - union select id,'forum' as selected, type

Re: mysql UNION

2005-06-05 Thread Michael Stassen
the one-statement-in-sql version I sent in my first reply to Mathias' suggestions. It's just a matter of adding 2 conditions to each WHERE clause in the UNION, so I think it will meet your specs, even for your real query. Michael -- MySQL General Mailing List For list archives: http

Re: mysql UNION

2005-06-05 Thread Michael Stassen
') UNION SELECT id, 'faq' AS type, FROM faq WHERE ($cat = '' OR $cat = 'faq') UNION SELECT id, 'forum' AS type, FROM forum WHERE ($cat = '' OR $cat = 'forum') snip Michael you just gave me an idea.. maybe this is better: SET @cat = '$cat

Re: mysql UNION

2005-06-05 Thread Sebastian
= '' OR $cat = 'news') UNION SELECT id, 'faq' AS type, FROM faq WHERE ($cat = '' OR $cat = 'faq') UNION SELECT id, 'forum' AS type, FROM forum WHERE ($cat = '' OR $cat = 'forum') snip Michael you just gave me an idea.. maybe

Re: mysql UNION

2005-06-05 Thread Michael Stassen
Sebastian wrote: Ah.. OK. I'll give that a shot instead.. Also, now that i am doing some thinking on optimizing... should the $cat clause be present first in the where clause? since it decides if it should get results or not. for example: WHERE MATCH(...) AGAINST(... IN BOOLEAN MODE) AND

mysql UNION

2005-06-04 Thread Sebastian
i have a query with 3 union selects: SELECT id, 'news' AS type, FROM news UNION SELECT id, 'faq' AS type, FROM faq UNION SELECT id, 'forum' AS type, FROM forum which works just fine and selects everything from all 3 tables.. but say i want to make

  1   2   3   4   >