Bookmarks

Yahoo Gmail Google Facebook Delicious Twitter Reddit Stumpleupon Myspace Digg

Search queries

w2ksp4.exe, WwwxxXdbf, procmail "FROM_MAILER" patch, Use of assignment to $[ is deprecated at /usr/local/sbin/apxs line 86. , wwwxxx vim, mysql closing table and opening table, 800c5000, setgid operation not permitted, pciehp: acpi_pciehprm on IBM, WWWXXX.DBF

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