Creating view in mysql
My first view is "create or replace VIEW myview1(EQUATTED_INSTALLMENT,ADVANCE_HEAD) as select MB_recievable_from_society.equated_insta,MB_advance_to_society.advance_head from MB_recievable_from_society join MB_advance_to_society join MB_society_advance on MB_recievable_from_society.advance_code=MB_advance_to_society.advance_code and MB_advance_to_society.advance_code=MB_society_advance.advance_code and MB_society_advance.advance_code=MB_recievable_from_society.advance_code where MB_recievable_from_society.start_week>='2008-01-01' and MB_recievable_from_society.start_week<='2008-01-31' and MB_society_advance.s_code='S111' and MB_recievable_from_society.payment_status='Part Paid'" and it is displaying correctly to the query "select * from myview1" as follows: mysql> select * from myview1; +----------------------+--------------+ | EQUATTED_INSTALLMENT | ADVANCE_HEAD | +----------------------+--------------+ | 1000 | loan || 800 | advance |+----------------------+--------------+ 2 rows in set (0.00 sec) And my Second view is"create or replace VIEW myview2(EQUATTED_INSTALLMENT,ADVANCE_HEAD) as select MB_next_installment.equated_installment,MB_advance_to_society.advance_head from MB_next_installment join MB_advance_to_society on MB_next_installment.advance_code=MB_advance_to_society.advance_code where MB_next_installment.next_installment>='2008-01-01' and MB_next_installment.next_installment<='2008-01-31' and MB_next_installment.s_code='S111' and MB_next_installment.paid='Not Paid'" and it is also displaying correcty to the select query: mysql> select * from myview2; +----------------------+--------------+ | EQUATTED_INSTALLMENT | ADVANCE_HEAD | +----------------------+--------------+ | 3000 | loan || 100 | advance || 100 | advance || 100 | advance || 100 | advance |+----------------------+--------------+ 5 rows in set (0.00 sec) But when I try to create a new view combining myview1 and myview2 using UNION it is not coming properly, Why? Can any one help me? I am creating the thrid one as follows: mysql> create or replace VIEW myview3 as select * from myview1 UNION select * from myview2 -> ; Query OK, 0 rows affected (0.09 sec) mysql> select * from myview3; +----------------------+--------------+ | EQUATTED_INSTALLMENT | ADVANCE_HEAD | +----------------------+--------------+ | 1000 | loan || 800 | advance | | 3000 | loan || 100 | advance |+----------------------+--------------+4 rows in set (0.02 sec) (Here only four rows is coming, It should be 7 rows as it is combining the rows in myview1 and myview2. Why it comes only 4 rows and not 7??)Executing a select statement
Currently i'm working on RDBMS Connectors, i would like to know how to execute a select statement and can i use sub queries also.Pl. refer the following information below and let me know is there any changes required in the following code String sql = "select description from products" + "where product_id=" + "(select product_id from services where service_phone_num="+telephoneNumber +")"; try { EventBody[] queryResult = com.vitria.connectors.rdbms.RDBMSTransformationLib.sqlResultToStringArray( getToDRSDataBase(), sql); if (queryResult == null || queryResult.length == 0) { CommonMessages.logGenericTrace("No DRS reference information found"); } String[] resultset = (String[])queryResult[0].getJavaParameter("data"); String description = (String)resultset[0]; } catch(Throwable t) { CommonMessages.logGenericTrace("CRITICAL ERROR"); }