Nested query problem

This is a discussion on Nested query problem within the MySQL Database forums, part of the Database Forums category; I'm trying to write a query that will sum the quantities in the funds table for all dates that ...


Go Back   Usenet Forums > Database Forums > MySQL Database

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 09-20-2006
arod
 
Posts: n/a
Default Nested query problem


I'm trying to write a query that will sum the quantities in the funds
table for all dates that are less than the navDate in the nav table.
I'm trying to use a nested query but it doesn't work. It says 'Unknown
column 'NAV.navDate' in 'where clause'"
I'm assuming I'm using this wrong. Is it possible to do in this way?


SELECT navDate, nav, funds.theQuantity FROM navs AS NAV, (SELECT
SUM(quantity) as theQuantity FROM funds WHERE transactionDate <
NAV.navDate AND username='$user') AS funds WHERE navDate > (SELECT
MIN(transactionDate) FROM funds WHERE username='$user')

Reply With Quote
  #2 (permalink)  
Old 09-22-2006
Jerry Stuckle
 
Posts: n/a
Default Re: Nested query problem

arod wrote:
> I'm trying to write a query that will sum the quantities in the funds
> table for all dates that are less than the navDate in the nav table.
> I'm trying to use a nested query but it doesn't work. It says 'Unknown
> column 'NAV.navDate' in 'where clause'"
> I'm assuming I'm using this wrong. Is it possible to do in this way?
>
>
> SELECT navDate, nav, funds.theQuantity FROM navs AS NAV, (SELECT
> SUM(quantity) as theQuantity FROM funds WHERE transactionDate <
> NAV.navDate AND username='$user') AS funds WHERE navDate > (SELECT
> MIN(transactionDate) FROM funds WHERE username='$user')
>


Well, for one thing you can't use NAV like this - you'll have to use the
full table name (navs).

But I'm not real sure what you're trying to do here. And not having the
table layout, it's impossible to know how to code this.


--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@attglobal.net
==================
Reply With Quote
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
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

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT +1. The time now is 06:09 AM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0