-3

i am making web app using meteor with react and in my LedgerMaster.jsx is

   import React, { Component } from 'react';
   import { createContainer } from 'meteor/react-meteor-data';
   import { LedgerMasterApi } from '../../../api/ledgerMaster';
   import  LedgerMasterForm  from './LedgerMasterForm';
   import  LedgerMasterDiplay  from './LedgerMasterDiplay';
    class LedgerMaster extends Component {
    render(){
    return(
        <div>
          <LedgerMasterForm />
          <LedgerMasterDiplay ledgeres={this.props.ledgeres}  />
        </div>
       );
      }
    }
 export default createContainer(() => {
  return {
     ledgeres: LedgerMasterApi.find({}).fetch(),
    };
 }, LedgerMaster);

so the problem is i have to define my import { LedgerMasterApi } from '../../../api/ledgerMaster'; in both LedgerMasterForm for insertion and LedgerMasterDiplay for fetch data

Rizwan
  • 163
  • 2
  • 8
  • 1
    You tell us, what does it produce? – RiggsFolly May 09 '16 at 21:21
  • i am littleconfuse how would i print my categories and sub categories like above so i posted this question if some one helps me for this – Rizwan May 09 '16 at 21:24
  • 1
    Well show us an example of the resultset produced by the query – RiggsFolly May 09 '16 at 21:25
  • its showing invalid relational operator – Rizwan May 09 '16 at 21:31
  • which database product? You have this tagged with MySQL and Oracle - it can't be both. –  May 09 '16 at 21:35
  • Your categories and sub-categories have an id and a name. Are they ordered in any particular way? Or do you not care about the order in which the categories are listed, and then the order of the subcategories within each category? If you need them ordered, there must be additional information in the table; relational table rows are not ordered by default. –  May 09 '16 at 21:36
  • my mistake i apologize its oracle – Rizwan May 09 '16 at 21:36
  • c001 electronics c002 home appliances and sub categoris are sc001 mobile sc002 mobile with cat id c001 – Rizwan May 09 '16 at 21:40
  • Question came a little under-prepared, but does not deserve its high negative rating. Category / Subcategory listings seems to be a common problem for which I did not find a good answer yet on StackOverflow. I am sure if someone get's this properly answered, it will be useful for others. I did find a full-sql solution for this, but it does not lend itself well for a language with the concept of Cursors (ResultSets). – YoYo May 10 '16 at 08:34

2 Answers2

1

Im not sure. try this work what u want.

use this query.

SELECT category.catnap,sub_category.subcatname  FROM category
INNER JOIN sub_category ON TRIM(category.canid) = TRIM(sub_category.canid)  ORDER BY category.catnap ASC

use this code

while(rs.next()){
       out.println(rs.getString("catnap")+"."+rs.getString("subcatname"));
}
Sandun Chathuranga
  • 2,242
  • 2
  • 13
  • 27
  • your result should looks like this? `electronics.mobile electronics.Coumputer home appliances.AC home appliances.Freez furniture.Sofa` – Sandun Chathuranga May 11 '16 at 04:45
  • Ya kind a same bt category name shouldno repeat – Rizwan May 11 '16 at 15:32
  • Ya sir i did it thank you so much for your help . I did it in a diffrent way see below i have answered it . It cant be possible without you . Sir could you plz give your email id i want to be in contact with you – Rizwan May 12 '16 at 09:26
0
    rs=stat.executeQuery("select count(catname) as numRows, catname from category group by catname");
    while(rs.next()){
        String cat="";int count=0;
       int catrow=rs.getInt("numRows");
       for (int j=1;j<=catrow.length;j++){
           count=0;
           cat=rs.getString("catname");
           system.out.println(cat);
           rs1=stat.executeQuery("SELECT sub.subcatname from sub_category sub where sub.catid="+'cat'+);

           while(rs1.next()){
               system.out.println(rs1.getString("subcategory"));
               count++;
           }
       }

}
Bhugy
  • 711
  • 2
  • 8
  • 23
  • Needs some extra work: 1./ code won't compile, 2./ it has the beginnings of [sql injection](http://stackoverflow.com/questions/60174/how-can-i-prevent-sql-injection-in-php?rq=1), 3./ `count(catnap)` should be a simple count(*), unless you expect values to be null; 4./ poor query reuse - begs for a `PreparedStatement`. But with a little extra love, it can be recycled as the accepted answer. – YoYo May 10 '16 at 08:36
  • thanx alot Bhugy for your effort bt i will not work as i know that we cant put a query inside a another query – Rizwan May 10 '16 at 09:57
  • my project has stuck here can anyone help me for geting that output. – Rizwan May 10 '16 at 09:59