Php oracle multi database Query

Normaly if mysql or mssql i would do like below Database A : test1 Database B : test2 Database C : test3

Sql Statement :

select * FROM test1.table1  
join test2  on test1.table1.id  = test2.table2.id
join test3  on test1.table1.id  = test3.table4.id 

How it work in Oracle and Php ?

Answers


Ok, you need to create a database link in oracle at first:

CREATE DATABASE LINK dblink_name 
   CONNECT TO username IDENTIFIED BY password
   USING 'service_name';

Service_name is a record in your database's tnsnames.ora.

Or, if you don't want to use tnsnames.ora, you can specify your net name right in create function, like this:

CREATE DATABASE LINK dblink_name 
     CONNECT TO username IDENTIFIED BY password
     USING '(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=hostname)(PORT=1521))(CONNECT_DATA(SID=dbname))';

and then use it this way:

SELECT host_name, instance_nmame FROM v$instance@dblink_name;

have you try it exactly the same way in PHP with MySQL?

<?php

$sql_statement = "SELECT
    PostID,
    AuthorID,
    Users.tblUsers.Username
    FROM tblPosts
    LEFT JOIN Users.tblUsers ON AuthorID = Users.tblUsers.UserID
    GROUP BY PostID,AuthorID,Username
    ";

$dblink = mysql_connect("somehost", "someuser", "password");
mysql_select_db("BlogPosts",$dblink);
$qry = mysql_query($sql_statement,$dblink);

?>

Need Your Help

launch gdb and print out variable value using ruby

ruby variables gdb inspect

I want to write a ruby program that could inspect the variable value of a program by launch the gdb and then print that value. How could I achieve this?

Selectors in Scheme R6RS

scheme r6rs

I'm reading a old book

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.