dbTalk Databases Forums  

Sum 2 select queries

comp.databases.mysql comp.databases.mysql


Discuss Sum 2 select queries in the comp.databases.mysql forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
contracer
 
Posts: n/a

Default Sum 2 select queries - 04-09-2011 , 07:54 AM






Please help me how can I sum the result of 2 select queries:

SELECT

COUNT(DISTINCT Nodes.Caption) AS COUNT_of_NodeName

FROM

Nodes

WHERE

(

(Nodes.Status = '1') AND

(Nodes.Link = 1)

)











SELECT

COUNT(Interfaces.InterfaceName) AS COUNT_of_Interface_Name

FROM

Interfaces

WHERE

(

(Interfaces.Link = 1) AND

(Interfaces.Status = '1')

)

Reply With Quote
  #2  
Old   
Luuk
 
Posts: n/a

Default Re: Sum 2 select queries - 04-09-2011 , 08:15 AM






On 09-04-2011 14:54, contracer wrote:
Quote:
Please help me how can I sum the result of 2 select queries:


UNION ALL
http://dev.mysql.com/doc/refman/5.1/en/union.html
--
Luuk

Reply With Quote
  #3  
Old   
onedbguru
 
Posts: n/a

Default Re: Sum 2 select queries - 04-09-2011 , 08:58 AM



On Apr 9, 8:54*am, contracer <contrace... (AT) gmail (DOT) com> wrote:
Quote:
Please help me how can I sum the result of 2 select queries:

SELECT

COUNT(DISTINCT Nodes.Caption) AS COUNT_of_NodeName

*FROM

Nodes

*WHERE

(

* (Nodes.Status = '1') AND

* (Nodes.Link = 1)

)

SELECT

COUNT(Interfaces.InterfaceName) AS COUNT_of_Interface_Name

*FROM

Interfaces

*WHERE

(

* (Interfaces.Link = 1) AND

* (Interfaces.Status = '1')

)
not sure that the sum of these two queries is what you really
want???? example: (nodes=3 + interfaces=6 = 9)???

Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.