Professional Web Applications Themes

Nested query problem - MySQL

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')...

  1. #1

    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')

    arod Guest

  2. #2

    Default Re: Nested query problem

    arod wrote: 

    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.
    net
    ==================
    Jerry Guest

Similar Threads

  1. Nested query results
    By IanHindle in forum Coldfusion Database Access
    Replies: 9
    Last Post: February 7th, 04:42 PM
  2. Query without Nested
    By BenAmy in forum Coldfusion Database Access
    Replies: 1
    Last Post: July 1st, 01:44 AM
  3. problem with nested grid
    By jhony blades in forum ASP.NET Data Grid Control
    Replies: 0
    Last Post: December 27th, 05:11 PM
  4. Nested FOR-EACH in XSLT sheet problem
    By Yuri Vorontsov in forum FileMaker
    Replies: 0
    Last Post: July 24th, 09:22 AM
  5. RadioButtonList in Nested DataGrid Problem
    By Bob Hoke in forum ASP.NET General
    Replies: 0
    Last Post: July 11th, 06:28 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139