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 FROM form15 f15 
WHERE f15.Form15SampleTube6RnaBarcode IN ('01D2V','01DH6'))as abc


Cheers :)


Neeraj Black Bits

-Original Message-
From: Luke [mailto:[EMAIL PROTECTED] 
Sent: Wednesday, May 24, 2006 9:36 AM
To: mysql@lists.mysql.com
Subject: Query problem: UNION in subquery

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 f15 
WHERE f15.Form15SampleTube1RnaBarcode IN ('01D2V','01DH6')) 


UNION 


(SELECT f15.Form15SampleTube6RnaBarcode AS ObjectId, 
f15.Form15PatientID  AS PtId FROM form15 f15 
WHERE f15.Form15SampleTube6RnaBarcode IN ('01D2V','01DH6')) 


2. 
This works fine too /subquery/: 


SELECT ObjectId FROM 


(SELECT f15.Form15SampleTube1RnaBarcode AS ObjectId, 
f15.Form15PatientID AS PtId FROM form15 f15 
WHERE f15.Form15SampleTube1RnaBarcode IN ('01D2V','01DH6')) AS 
SubTable1; 


3. 
But when I run 12 combined I get in troubles. This is a query draft, 
can't come up with the right syntax: 


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 FROM form15 f15 
WHERE f15.Form15SampleTube6RnaBarcode IN ('01D2V','01DH6')) 


I tried many combinations and got various syntax errors. Any ideas? 


Thanks, 
Luke 



-- 
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]




-- 
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]



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]; mysql@lists.mysql.com
Sent: Wednesday, May 24, 2006 2:16 AM
Subject: RE: Query problem: UNION in subquery




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 FROM form15 f15
WHERE f15.Form15SampleTube6RnaBarcode IN ('01D2V','01DH6'))as abc


Cheers :)


Neeraj Black Bits

-Original Message-
From: Luke [mailto:[EMAIL PROTECTED]
Sent: Wednesday, May 24, 2006 9:36 AM
To: mysql@lists.mysql.com
Subject: Query problem: UNION in subquery

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 f15
WHERE f15.Form15SampleTube1RnaBarcode IN ('01D2V','01DH6'))


UNION


(SELECT f15.Form15SampleTube6RnaBarcode AS ObjectId,
f15.Form15PatientID  AS PtId FROM form15 f15
WHERE f15.Form15SampleTube6RnaBarcode IN ('01D2V','01DH6'))


2.
This works fine too /subquery/:


SELECT ObjectId FROM


(SELECT f15.Form15SampleTube1RnaBarcode AS ObjectId,
f15.Form15PatientID AS PtId FROM form15 f15
WHERE f15.Form15SampleTube1RnaBarcode IN ('01D2V','01DH6')) AS
SubTable1;


3.
But when I run 12 combined I get in troubles. This is a query draft,
can't come up with the right syntax:


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 FROM form15 f15
WHERE f15.Form15SampleTube6RnaBarcode IN ('01D2V','01DH6'))


I tried many combinations and got various syntax errors. Any ideas?


Thanks,
Luke



--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]








--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:http://lists.mysql.com/[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 f15 
WHERE f15.Form15SampleTube1RnaBarcode IN ('01D2V','01DH6')) 



UNION 



(SELECT f15.Form15SampleTube6RnaBarcode AS ObjectId, 
f15.Form15PatientID  AS PtId FROM form15 f15 
WHERE f15.Form15SampleTube6RnaBarcode IN ('01D2V','01DH6')) 



2. 
This works fine too /subquery/: 



SELECT ObjectId FROM 



(SELECT f15.Form15SampleTube1RnaBarcode AS ObjectId, 
f15.Form15PatientID AS PtId FROM form15 f15 
WHERE f15.Form15SampleTube1RnaBarcode IN ('01D2V','01DH6')) AS 
SubTable1; 



3. 
But when I run 12 combined I get in troubles. This is a query draft, 
can't come up with the right syntax: 



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 FROM form15 f15 
WHERE f15.Form15SampleTube6RnaBarcode IN ('01D2V','01DH6')) 



I tried many combinations and got various syntax errors. Any ideas? 



Thanks, 
Luke 




--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]