sql - How to combine results of two tables when constraint key of one table has few null values -


i having 2 tables 1 accomodation , 1 hotelpaymententry want combine both tables without repeating same enquiry_id. below tables , query tried , result: table accomodation

enquiry_id             checkin      checkout    hotelname              amount rh - 26/02/2014 - 10 2014-03-18 2014-03-19  spice routes houseboats     15500 rh - 04/03/2014 - 1  2014-03-19 2014-03-20  spice routes houseboats     9000 rh - 04/03/2014 - 2  2014-03-17 2014-03-18  spice routes houseboats     24000 rh - 05/03/2014 - 6  2014-04-04 2014-04-05  spice routes houseboats     9000 rh - 10/03/2014 - 3  2014-06-17 2014-06-18  spice routes houseboats     33000 

table hotelpyamententry

![enter image description here][1]   hotel                   enquiryid         checkin    checkout   totalamount  paynow  dateofpayment   spice routes houseboats     null             null       null        null        5000    2014-12-09 spice routes houseboats     null             null       null        null        6000    2014-12-10 spice routes houseboats rh - 10/03/2014 - 3  2014-06-17 2014-06-18  33000      15000    2014-12-08 

i tried join n union both result inner join returns common records , left & right join multiplies records , return 5*3 records , union returns both tables records repeating enquiry_id rh - 10/03/2014 - 3 means total 8 records. want record both tables if enquiryid matches in both tables record appears once , if record unique in own table appears a=in output table. badly needed. in advance.

enter image description here

  select enquiry_id,checkin,checkout,hotelname,amount table accomodation     union //union doesn't take redundant data     select enquiry_id,checkin,checkout,hotelname,amount table hotelpyamententry 

Comments

Popular posts from this blog

java - Plugin org.apache.maven.plugins:maven-install-plugin:2.4 or one of its dependencies could not be resolved -

Round ImageView Android -

How can I utilize Yahoo Weather API in android -