sql - Write a query to fetch data from two database -
followings table name.both database have same table , column name.
field_data_field_name | entity_id| field_name_value| | 1 | xyz | field_data_field_address ----------------------------------- | entity_id | field_address_value| | 1 | abc | field_data_field_county ---------------------------------- | entity_id | field_county_value| | 1 | bombay | field_data_field_select_area --------------------------------------- | entity_id | field_select_area_value| | 1 | pension | users ------------------------------------ | uid | mail service | | 1 | sopu.phadke080@gmail.com |
in single database on basis of entity_id=uid bring together tables , info fetch successfully.
following query single database. select field_data_field_name.field_name_value, field_data_field_address.field_address_value, field_data_field_county.field_county_value, field_data_field_select_area.field_select_area_value, users.mail users inner bring together field_data_field_name on field_data_field_name.entity_id= uid inner bring together field_data_field_address on field_data_field_address.entity_id = uid inner bring together field_data_field_county on field_data_field_county.entity_id = uid inner bring together field_data_field_select_area on field_data_field_select_area.entity_id = uid
i create query not working.please help me.
select a.field_name_value, b.field_address_value, c.field_county_value, d.field_select_area_value, e.field_name_value, f.field_address_value, g.field_county_value, h.field_select_area_value dbeng.field_data_field_name a, dbeng.field_data_field_address b, dbeng.field_data_field_county c, dbeng.field_data_field_select_area d, inner bring together dbspa.field_data_field_name e on <field_data_field_name.field_name_value>=<field_data_field_name.field_name_value>, inner bring together dbspa.field_data_field_address f on <field_data_field_address.field_address_value>=<field_data_field_address.field_address_value>, inner bring together dbspa.field_data_field_county g on <field_data_field_county.field_county_value>=<field_data_field_county.field_county_value>, inner bring together dbspa.field_data_field_select_area h on <field_data_field_select_area.field_select_area_value>=<field_data_field_select_area.field_select_area_value> d.field_select_area_value ='pensión compensatoria' && h.field_select_area_value ='pensión compensatoria' && c.field_county_value ='alameda' && g.field_county_value='alameda'
the concept of storing such info in 2 different databases not sound right, if need info both, have union all
:
select x.col1, x.col2 ( select a.col1, b.col1 db1.a bring together db1.b on ( ... ) union select a.col1, b.col1 db2.a bring together db2.b on ( ... ) ) x x.col1 = ...
sql database
No comments:
Post a Comment