lundi 14 mars 2016

how to get data from three tables

i have three different table that contains items in invoice

1. Financial_item table

|fin_id item unit_price desc |

2. Invoice_item table

|item_id item uprice quan key_id_financial invoice_id |

3. invoice_table

|inv_id inv_name creation_date inv_item_id |

now i'm going to select query to join this three table for retrieving item name when fin_id = key_id_financial and item_id=inv_item_id where creation date is from this date to this

I have written a query for this but its not execute proper

"select DISTINCT "+Constants.TABLE_NAME_ITEM +"."+ Constants.ITEM_NAME + "," 
                                 + Constants.TABLE_NAME_ITEM +"."+ Constants.ITEM_UNIT_PRIZE +" from " + 
                                   Constants.TABLE_NAME_ITEM + " JOIN " + Constants.TABLE_NAME_INVOICE_ITEM +
                                  " JOIN "+ Constants.TABLE_NAME_INVOICE 
                                  + " ON "+ Constants.TABLE_NAME_ITEM +"."+Constants.ITEM_ID +"="+
                                  Constants.TABLE_NAME_INVOICE_ITEM+"."+Constants.FINANCIAL_KEY_ITEM +" AND "
                                  +Constants.TABLE_NAME_INVOICE+"."+Constants.INVOICE_KEY_ID +"="
                                  +Constants.TABLE_NAME_INVOICE_ITEM+"."+Constants.INVOICE_ITEM_ID +
                                  " WHERE " +
                                  Constants.TABLE_NAME_INVOICE +"."+Constants.INVOICE_CREATION_DATE  
                                  + " Between '" + epichFrom +"' AND '"+ epichTo+"'";`

Aucun commentaire:

Enregistrer un commentaire