Jd has replaced JDB as the Jsoftware database product for some time
now. Jd supports the kind of query you are looking for.


On Mon, Nov 23, 2015 at 10:39 PM, Ryan Eckbo <ec...@cim.mcgill.ca> wrote:
> I'm learning jdb, and have run into a weird issue: when I run a query
> with a where clause requiring the equivalence of two columns, I get
> an empty result, even though it should be nonempty.  For example,
>
>  Reads__d 'winner,team from teammatch'
> ┌──────┬────┐
> │winner│team│
> ├──────┼────┤
> │SYD   │CAR │
> │SYD   │SYD │
> │ESS   │ESS │
> │ESS   │FIT │
> └──────┴────┘
>    Reads__d 'winner,team from teammatch  where winner=team'
> ┌──────┬────┐
> │winner│team│
> ├──────┼────┤
> └──────┴────┘
>
> Both fields are type 'char', and are from separate tables.  I've pasted
> some sample code below.  Does anyone see the problem?
>
> thanks,
> Ryan
>
> ----------------------------------------
> NB. requires that folder 'dbs' exists
>
> require'data/jdb csv'
>
> boxcsv=.([: <;._1 ','&,);._2
> dataFromCsv=:<"_1@:|:@:}.    NB. strip header and box columns
> fixCol=: >each@{`[`]}        NB. make unboxed column
> fixNumCol=: ".@>each@{`[`]}  NB. make unboxed numeric column
>
> NB. match info, one row per match
> CSV_matches=: boxcsv (0 : 0)
> matchid,date,attendance,venue,winner,won_by,extra_time
> 1990-01-00,Sat 31-Mar-1990 2:10 PM,22427,Princes Park,SYD,5,0
> 1990-01-01,Sat 31-Mar-1990 2:10 PM,18960,Windy Hill,ESS,81,0
> )
>
> NB. match info per team, 2 rows per match
> CSV_teammatches=: boxcsv (0 : 0)
> matchid,team,score_progression,score
> 1990-01-00,CAR,6.5  10.9 12.15 14.15,99
> 1990-01-00,SYD,2.1   3.6   9.9 15.14,104
> 1990-01-01,ESS,7.4 13.11 17.15 20.21,141
> 1990-01-01,FIT,3.1   5.5   6.8  8.12,60
> )
>
> MatchData=: 4 fixCol 2 5 6 fixNumCol dataFromCsv CSV_matches
> TeamMatchData=: 1 fixCol 3 fixNumCol dataFromCsv CSV_teammatches
>
> MatchCols=: 0 : 0
> matchid varchar;
> date varchar
> att int
> venue varchar
> winner char
> wonby int
> extratime boolean
> )
>
> TeamMatchCols=: 0 : 0
> matchid match
> team char
> score_progression varchar
> score int
> )
>
> f=: Open_jdb_ 'dbs'
> Drop__f 'afltest'
> d=: Create__f 'afltest'
> Create__d'match';MatchCols; <MatchData
> Create__d'teammatch';TeamMatchCols; <TeamMatchData
>
> smoutput Reads__d '** from teammatch'
> smoutput Reads__d '** from teammatch where winner=team'  NB. Empty!
> ----------------------------------------------------------------------
> For information about J forums see http://www.jsoftware.com/forums.htm
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to