 |
AppletTalk.com Java discussions newsgroups
|
| View previous topic :: View next topic |
| Author |
Message |
kjc Guest
|
Posted: Thu Aug 26, 2004 9:14 pm Post subject: subselect or join |
|
|
Not sure if this is the right group to post this to but.
This is the current query that I have.
select tableA.id,tableB.artist,tableB.image,from tableA,tableB where
tableA.image = tableB.image AND tableB.price >0 AND tableB.price < 20
order by tableB.price DESC'
What I need is, for each row returned I need information from a third
and fourth table. tableC, and tableD.
tableC has information ( the tableA.id = tableC.eventId) that I need to
obtain tableC.accountId = tableD.accountID in order do select the
the binding information in tableD between a Vendor(name,address..etc..)
and tableB.image
Any help would be greatly appreciated.
|
|
| Back to top |
|
 |
Erwin Moller Guest
|
Posted: Tue Sep 07, 2004 8:39 am Post subject: Re: subselect or join |
|
|
kjc wrote:
| Quote: | Not sure if this is the right group to post this to but.
This is the current query that I have.
select tableA.id,tableB.artist,tableB.image,from tableA,tableB where
tableA.image = tableB.image AND tableB.price >0 AND tableB.price < 20
order by tableB.price DESC'
What I need is, for each row returned I need information from a third
and fourth table. tableC, and tableD.
tableC has information ( the tableA.id = tableC.eventId) that I need to
obtain tableC.accountId = tableD.accountID in order do select the
the binding information in tableD between a Vendor(name,address..etc..)
and tableB.image
Any help would be greatly appreciated.
|
Hi,
That is kind of hard to say.
You need to define which rows from TableC and TableD you want in your set.
So how they should be joined.
It is also perfectly possible your database is designed in poor way.
Check this for a primer on SQL:
http://www.w3schools.com/ and check SQL
Regards,
Erwin Moller
|
|
| Back to top |
|
 |
Chuck Simpson Guest
|
Posted: Sun Sep 12, 2004 8:17 pm Post subject: Re: subselect or join |
|
|
On Thu, 26 Aug 2004 21:14:15 +0000, kjc wrote:
| Quote: | Not sure if this is the right group to post this to but.
This is the current query that I have.
select tableA.id,tableB.artist,tableB.image,from tableA,tableB where
tableA.image = tableB.image AND tableB.price >0 AND tableB.price < 20
order by tableB.price DESC'
What I need is, for each row returned I need information from a third and
fourth table. tableC, and tableD.
tableC has information ( the tableA.id = tableC.eventId) that I need to
obtain tableC.accountId = tableD.accountID in order do select the the
binding information in tableD between a Vendor(name,address..etc..) and
tableB.image
Any help would be greatly appreciated.
|
You probably want something like the following:
select
a.id, b.image, b.artist,
c.*, d.*
from
tableA a,
tableB b,
tableC c,
tableD d
where
a.image = b.image and
b.price > 0 and
b.price < 20 and
a.id = c.eventId and
c.accountId = d.accountId
You can specify the fields you need from tableC and tableD instead
of using c.* and d.* as I did in the select list.
Chuck
|
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|