Bookmarks

Yahoo Gmail Google Facebook Delicious Twitter Reddit Stumpleupon Myspace Digg

Search queries

phpmyadmin fehler rechte unerlaubte mischung, WWWXXXApc, lilo trying to map files from unnamed device 0x0000", Wwwxxxapc, CAM::PDF::Renderer::TextF Fragen, adodb.recordset error '800a0cc1', php save mails as eml, WWWXXXAPC, sqlexpress database file auto-creation error, sqlexpress database file auto-creation error

Links

XODOX
Impressum
Datenschutz

#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