Bookmarks

Yahoo Gmail Google Facebook Delicious Twitter Reddit Stumpleupon Myspace Digg

Search queries

bind-address mysql multiple, sanibleone xxxx, ftp://192.168.100.100/, www.xxxcon, which comes first ob_start or session, wwwxxx/58/2010, xxxxdup, xxxxdup, mailx informatii, should producers of software-based services, such as atms, be held liable for economic injuries suffered when their systems fail?

Links

XODOX
Impressum

#1: linking two selects

Posted on 2007-11-10 15:08:35 by mantrid

I have two select statements below, that I wish to combine into one

SELECT cgttransactions.linkid, cgttransactions.userid,
cgttransactions.myvarid, cgttransactions.companyid,
Sum(cgttransactions.amount) AS SumOfamount, Avg(cgttransactions.price) AS
AvgOfprice, Sum(cgttransactions.stamp) AS SumOfstamp,
Sum(cgttransactions.comm) AS SumOfcomm, cgttransactions.datetime,
cgttransactions.aimlisted
FROM cgttransactions
GROUP BY cgttransactions.linkid, cgttransactions.userid,
cgttransactions.myvarid, cgttransactions.companyid,
cgttransactions.datetime, cgttransactions.aimlisted
HAVING (((cgttransactions.userid)="1") AND ((cgttransactions.myvarid)=1) AND
((cgttransactions.companyid)="1"));



SELECT cgttransactions.linkid, cgttransactions.sellprice,
cgttransactions.sellcomm, cgttransactions.selldatetime
FROM cgttransactions;

the common field is linkid
How do I do this?
Thanks

Report this message

#2: Re: linking two selects

Posted on 2007-11-12 21:13:41 by Michael Austin

mantrid wrote:
> I have two select statements below, that I wish to combine into one
>
> SELECT cgttransactions.linkid, cgttransactions.userid,
> cgttransactions.myvarid, cgttransactions.companyid,
> Sum(cgttransactions.amount) AS SumOfamount, Avg(cgttransactions.price) AS
> AvgOfprice, Sum(cgttransactions.stamp) AS SumOfstamp,
> Sum(cgttransactions.comm) AS SumOfcomm, cgttransactions.datetime,
> cgttransactions.aimlisted
> FROM cgttransactions
> GROUP BY cgttransactions.linkid, cgttransactions.userid,
> cgttransactions.myvarid, cgttransactions.companyid,
> cgttransactions.datetime, cgttransactions.aimlisted
> HAVING (((cgttransactions.userid)="1") AND ((cgttransactions.myvarid)=1) AND
> ((cgttransactions.companyid)="1"));
>
>
>
> SELECT cgttransactions.linkid, cgttransactions.sellprice,
> cgttransactions.sellcomm, cgttransactions.selldatetime
> FROM cgttransactions;
>
> the common field is linkid
> How do I do this?
> Thanks
>
>

a google search for mysql and join should provide you with some
interesting links on how and what "joins" are.

This is an example (I in no way am related to this link - it was one of
search result links) :
http://www.codinghorror.com/blog/archives/000976.html

Report this message