Matching data in two databases

Hi
I am trying to collect data from one database and match the result of the first datatbase to the second databases data. I Then want to echo the matches ranked based on the number of matches found for the individual variables. The echo would have a maximum of 20 results.
This is some of my early trials could some one help me please.
<? Php
connect=include('connect.php')
//This code sets the current logged in individual.
$id= $_SESSION['id'];
$person=mysql_query("SELECT * FROM Users WHERE id='$id'")
//This echos the data results from the database query.
while($row=mysql_fetch_assoc($person))
echo ' $rows['age'];
       $rows['country'];
       $rows['city'];
       $rows  
// This querys the second database. The plan is to display and rank at least 20 results based on how closely
they match the first queries results. I first created viarables of the first database results.
$age=$rows['age'];
$country=$rows['country'];
$city=$rows['city'];
// This queries the second datbase.
$account=mysql_query("SELECT * FROM account WHERE ages='$age', country='$country' city='$city'")
//This echos the result
while($num=mysql_fetch_assoc($account))
echo 'num['age'];
      num['country'];
      num['city'];';
      num['otherdata'];
// otherdata variable output other data in the database from the multiple echoed results.
I want to limit the results to 20 and rank them according to the most matching from first database results. Please help. Just reply if any part does make sense.

If they are in the same database then you would use a simple join. But it is not clear from your requirements how you are trying to 'match' the fields in the two tables. You would need to post detailed requirements for us to be of any help. Some context would also be helpful.

Similar Messages

  • Creating BAM report using data of two database tables. Say "EmployeeTable" and "DepartmentTable

    I want to populate data from two database tables into a BAM report. I have created two data objects for the tables and want to create 3rd data object so that it can take the data from the other data objects automatically. Is there any such facility within BAM?

    Hi
    1. I am not sure if you have option to combine multiple DataObjects like that.
    2. For your scenario, on Database side itself, I would recommend Create a VIEW that joins these 2 Tables and pull the required Columns and add required conditions. Verify the VIEW has all the rows expected.
    3. Then create DataObject for this View. Once you have DataObject, create the Report.
    Thanks
    Ravi Jegga

  • Get data from two databases?

    Hello all,
    Do anyone know if it's posible to get data from two databases while I'm running SBO in one of them? I need this because our client wants to be able to print reports with all the information stored in both companies. I searched this forum trying to find if this is possible but I did't find any information about this.
    Can someone help me?
    Thanks and regards,
    Mariana Mazzero

    Hi Mariana,
    What you can do is use two company objects to retrieve the data. As far as I know you're not restricted to one company connection.
    You can also just use a standard read only connection (like ADO/ODBC) to retrieve the data for the reports.
    Hope it helps,
    Adele

  • Synchronisation of data between two databases

    i have two databases having tables with same fields and i would like to transfer the data from one database to the other , how do i do that? is there any link which talks about synchronisation of data between two databases?

    Make the database name same in both databases and use Veritas tools for data copy.

  • SELECT data from two databases

    I have two databases that I need to select data from in a
    single SELECT. Using DWs Advanced window for creating the select I
    don't see any way to select more than 1 Connection. Both databases
    have unique user and passwords but reside on the same server. Any
    idea how I can write a single SELECT to get data from both dbs. I
    assumed it would be similar to selecting data from multiple tables
    within the same db but the connection part is stumping me. Any
    ideas would be greatly appreciated.

    TouchstonePress wrote:
    > Page 48, Developing a Web Database Application . . .
    speaks about making a
    > database with two related TABLES each with the same
    PRIMARY KEY column with
    > which to identify a customer using their unique number.
    That's the basic technique for joining two tables in the same
    database.
    The original poster has tables in different databases that
    have
    different user accounts and passwords.
    Although it's possible to join two databases, you cannot do
    it unless
    you have one user account with the same privileges on both
    databases.
    David Powers, Adobe Community Expert
    Author, "The Essential Guide to Dreamweaver CS3" (friends of
    ED)
    Author, "PHP Solutions" (friends of ED)
    http://foundationphp.com/

  • What is best method to retrieve data from two databases

    I'm writing a report that needs data from two sql databases. Not the same brand. Grouping and sorting fields come from both databases, so I can't just read one and retrieve data from the other. It seems to me I have to extract data from each data base using crystal reports, merge the two files using crystal reports and feed the merged file into crystal reports. I've not found a simpler or better method in the Crystal Reports documentation. Is there documentation about doing this process on the web site or with crystal reports documentation? My method seems cumbersome so I'm wondering if there is a better method.

    Jeffrey,
    A cheap and effective solution, for a periodic transfer would be using XML.
    If you have the DDL for all of the objects in the database, you can just duplicate it on whatever RDBMS engine you want, and then, extract the data, table per table into XML files from the target server, and then load the files into the target server.
    Otherwise, if you are going to do this in an ongoing basis, then, use SAP Replication Server. The best asynchronous, real time, heterogeous replication solution in the industry, exploited with a great deal of success by many critical mission financial applications with global topologies and sub second latency.
    My two cents.
    I hope they help.
    Regards,
    Jean-Pierre

  • Fetch Data from two Database

    I want to fetch data from two tables which are in two separate database. Is it possible to fetch similar from two schemas of same database.
    Pls help with query.

    Hi,
    Say you have two schema S1 and S2 in the same database 'xyz' then you can create two database links to these two schemas from any third schema as ::
    CREATE database link s1link connect to S1 identified by <password of S1> using 'xyz' ;
    CREATE database link s2link connect to S2 identified by <password of S2> using 'xyz' ;
    Now say if there is a table called tab1 in schema S1, then you can get data from it as ::
    SELECT T1.*
    FROM tab1@s1link T1
    WHERE < you can put conditions here> ;
    Similarly for the columns of a table of schema S2.
    - Thanks
    Sandipan

  • Data from Two database

    Is it possible to get data in one report
    from two different database(Oracle,Sybase)
    Thank You

    <BLOCKQUOTE><font size="1" face="Verdana, Arial">quote:</font><HR>Originally posted by nirali:
    Is it possible to get data in one report
    from two different database(Oracle,Sybase)
    Thank You<HR></BLOCKQUOTE>
    Check www.attunity.com Attunity Connect does that - hetrogenous joins
    null

  • Transfer large data between two databases via ODI

    Hi, we want to transfer our 2 billion records (70gb) A database oracle server to B database oracle server via ODI LKM SQL to Oracle (SQLLDR).We use a filter like "prod_enter_date>sysdate-1" for daily  records(about 200.000).It takes about 1 our.How can we transfer data faster, thanks  for your advice.

    OK so assuming the Oracle DB's can see each on the network other have a word with your DBA's about creating a DBLink and test out the LKM DB Link KM.
    Also try Uli's amended LKM if dont want to be too intrusive on your souce system creating synonyms etc. : http://sonra.io/tag/lkm-db-links/
    I have used both and they work fine.
    Basically you are currently unloading a large amount of data, transfering to another location and then uploading that data with no transformation to the target environment, a DBLink LKM will transfer this data without the need to unload / upload , just the network transfer.
    Another thread here : https://forums.oracle.com/message/9630782
    To re-quote the that thread quoting the documentaion for that LKM : "As it says in the component description - "This module is recommended when developing interfaces between two Oracle servers."

  • Technique to pass data between two databases

    I am developing a web application with an offline client.
    for offline client am using embedded mysql using mysql-je http://mysql-je.sourceforge.net/
    for online ie for overall application( server ) am using mysql 5.0.
    i want to update data from client to server and also from server to client .
    pls tell me is how i can implements this ?...
    Message was edited by:
    vp_anil

    The other reply is about connectivity only. If you have connectivity then it isn't relevant. If you don't then you can't do anything.
    So ignoring that....
    >
    pls tell me is how i can implements this ?...It depends on your data.
    Basically you can have the following data problems
    A. Add rows
    B. Delete rows
    C. Modify rows
    You can also have two directions
    1. Client to main database.
    2. Client from main database.
    In terms of solution.
    - Decide direction.
    - Add rows - use a creation time stamp. Get last update timestamp then moving anything newer.
    - Delete rows. Harder than add because either you have to keep a record of deleted entries or you have to compare the entire existing set and look for holes. Once you find existing entries then delete them.
    - Modify. Much harder and it depends on the data. It should also be considered whether manual verification is required. For instance can the customer address (stored in the database) be updated both on the clien and the main database? If yes then which one is right? What if the address was updated in both places and then a day later the phone number was updated? Two changes and maybe one is right in one place and one is right in the other. A replay log might help here but maybe not.

  • Matching data for two internal Table

    hi guru's,
    i have two internal table that is ITAB and itab1, and both has more than 2000 records, but MATNR is common field in both, so i want to update itab from itab1 according to matnr. can anyone please help me? actually i was using read table but it was not doing correct.
    regards Nitin.

    dear all,
    thanx for reply again...but still same problem. actually i m making a report for material price comparison
    purchased in current month and same material if purchased in before months. so i need maintain the final ITAB with including same material if purchased in previus months.
    ITAB1 :   EBELN      BLDAT       MATNR    WRBTR
                 100023     20080101      abcd        100.00
                 100025     20080106      xyzr         250.00
                 100028     20080102      abcd        100.00
                 100129     20080117      xyzr         150.00
                 100159     20080126       uvwx        170.00
    ITAB2 :   EBELN      BLDAT1       MATNR    WRBTR1
                 200026     20080201      abcd        105.00
                 200024     20080206      xyz_r4      250.00
                 200023     20080201      abcd        100.00
                 200129     20080217      xyzrw        150.00
                 200152     20080225      uvwx        190.00
    Final record which i need.
    ITAB3:  EBELN      BLDAT       MATNR    WRBTR   WRBTR1
                       100023     20080101      abcd        100.00     105.00
                       100023     20080101      abcd        100.00     105.00
                       100159     20080126       uvwx        170.00    190.00
    please suggest me accordingly...
    regards nitin.

  • Updating data in mulitple databases

    Hi,
    I have a requirement in my project to update the data in two databases, when user updates data in the screen and saves it. We are using stateless session EJB to call the DAO. The update is using normal JDBC update statement.
    If some thing goes wrong in update stmt in any of the database, does EJB has capability to rollback the update in another database as well. As both are in single transaction.
    Pls advise on this. Your help is appreciated.
    Thanks
    Kumar.

    ... I only added this constructor to be able to run your code:
        public fillDbGui(){
            setTitle("Fill DB GUI");
            setSize(600,500);
            setLocationRelativeTo(null);
            try{
                DriverManager.registerDriver( new com.mysql.jdbc.Driver() );
                DriverManager.registerDriver( new sun.jdbc.odbc.JdbcOdbcDriver() );
                connection = DriverManager.getConnection(DATABASE_URL, DATABASE_USER, USER_PASSWORD);
                conc = connection.createStatement();
                System.out.println("Successfully connected to database '" +DATABASE_NAME+ "'\n");
            }catch(SQLException ex){
                System.out.println("Connection failed\n");
                JOptionPane.showMessageDialog( this, ex.getMessage(),
                        "Fill_DB_GUI:   SQLException", JOptionPane.ERROR_MESSAGE);
            db2vector();
        public static void main(String args[]) {
            new fillDbGui().setVisible(true);
        private final String DATABASE_NAME = "test";
        private final String DATABASE_URL =  "jdbc:mysql://localhost:3306/" + DATABASE_NAME;
    //    private final String DATABASE_URL = "jdbc:odbc:" + DATABASE_NAME;
        private final String TABLE_NAME = "testuhrand";
        private final String DATABASE_USER = "root";
        private final String USER_PASSWORD = "sql";
        private Statement conc;
        private Connection connection;

  • Two databases

    Hi All,
    I am have an issue to grab data from two databases using select query, Could any one can help me in this regard with example
    Thanks,
    RED

    Suppose you have two database A and B.
    You are in database A and want to run query which will relate table from both the databases. I think, That is want you need.
    For that after creating DB link from the syntax shown in link it will be
    SELECT a.*, bb.*
    FROM A, B@DB_LINK bb
    WHERE a.a1 = bb.a1;
    Hope it clears.
    One more link:
    http://www.psoug.org/reference/db_link.html
    http://www.lazydba.com/oracle/0__97467.html
    http://www.mydigitallife.info/2006/01/14/oracle-database-link/

  • Cartesian of data from two tables with no matching columns

    Hello,
    I was wondering – what’s the best way to create a Cartesian of data from two tables with no matching columns in such a way, so that there will be only a single SQL query generated?
    I am thinking about something like:
    for $COUNTRY in ns0: COUNTRY ()
    for $PROD in ns1:PROD()
    return <Results>
         <COUNTRY> {fn:data($COUNTRY/COUNTRY_NAME)} </COUNTRY>
         <PROD> {fn:data($PROD/PROD_NAME)} </PROD>
    </Results>
    And the expected result is combination of all COUNTRY_NAMEs with all PROD_NAMEs.
    What I’ve noticed when checking query plan is that DSP will execute two queries to have the results – one for COUNTRY_NAME and another one for PROD_NAME. Which in general results in not the best performance ;-)
    What I’ve noticed also is that when I add something like:
    where COUNTRY_NAME != PROD_NAME
    everything is ok and there is only one query created (it's red in the Query plan, but still it's ok from my pov). Still it looks to me more like a workaround, not a real best approach. I may be wrong though...
    So the question is – what’s the suggested approach for such queries?
    Thanks,
    Leszek
    Edited by xnts at 11/19/2007 10:54 AM

    Which in general results in not the best performanceI disagree. Only for two tables with very few rows, would a single sql statement give better performance.
    Suppose there are 10,000 rows in each table - the cross-product will result in 100 million rows. Sounds like a bad idea. For this reason, DSP will not push a cross-product to a database. It will get the rows from each table in separate sql statements (retrieving only 20,000 rows) and then produce the cross-product itself.
    If you want to execute sql with cross-products, you can create a sql-statement based dataservice. I recommend against doing so.

  • APEX Application accessing data from two different databases

    Hi All,
    Currently as we all know that APEX Application resides in database and is connected to the schema of that database.
    I want APEX Application to be running and accessing data from two different databases. Elaborating my question,
    Currently, my APEX Production Application is connected with XXXX Schema of DB1 Database(Where APEX Resides). Now I want to add some pages into this APEX Application for REPORT Purpose, But I want to connect this REPORT APEX Pages to get data from Different Schema YYYY for Database DB2.
    Is it possible to configure this scenario?
    The reason for doing this is to avoid the REPORT related (adhoc queries) resource utilization effect on Production DB1 Database.
    Thanks
    Nil

    1. If you do the joining of two or more tables in DB1 then all data is pulled over to DB1 and then the join is executed: so more data over the databaselink and more work for DB1. Better keep the joining stuff where the data resides and just pull exactly that data over that you need.
    2. Don't know about your different block sizes. Seems a nice question for one of the other forums (DBA or SQL).
    3. I mean create synonyms on DB1 for reports VIEWS in DB2.
    Hope all is clear!

Maybe you are looking for

  • Data loads from 2 dsos to 1 infocube

    Hi all, I am trying to update data from DSO1 (Source1: transaction data) to Infocube(TARGET) In the transformations Start routine, I have to read DSO2(Source2: Master data) for some fields. DSO1 has CUSTOMER as part of key DSO2 has CUSTOMER (key) and

  • I Want My Smart Playlists To Update On MY iPod

    Hi, I have a fifth generation ipod with software version 1.3, which no longer updates smart playlists on the go. I was hoping that apple would release an update, but it looks like they've moved on. So, I'm hoping that I can download and install 1.2 (

  • Upgrade Solaris 2.5.1 to 2.6

    Hi all, I am very new and unfamilliar with the SunSolaris OS ; actually I was recently upgraded from Oracle Developer/Analyst to Oracle DBA. So I have a server (which I access remotely) with Solaris 2.5.1 , and I need to install Oracle 8i(8.1.6.0) on

  • Quick Poll Greyed Out  - unable to edit

    Hello, We have a series of quick polls assigned to individual campaigns and all are 'ongoing'.  These are then assigned to KM IViews and assigned to users via roles etc. Last week we were able to edit the quick poll, editing the text, participants et

  • How to change address book listings in Leopard not by first name first?

    I was recently upgraded from Tiger to Leopard. Suddenly the names in my computer address book are listed by first names first, ALICE BROWN. How can I change this back to the way it used to be in Tiger, listing the last name first,, BROWN, ALICE ?