Follow Me
Subscribes Hell Buddy Solution.

Google+
^
Back To Top

Feel Glad finally done the Meta Tags generator and video :) project
- type: seo html - 30 September 2014 Tue @Hell Buddy

close
Home Message Share Translate

MySQL - How to combine tables from different databases?

30July 2014
Wednesday



How to combine 2 different tables from different databases?

We can use very simply way to get a concept for combining 2 different tables, even from different databases.

When you login phpMyAdmin, don't get in any database, put yourself out of the loop; choose the localhost server and run the following MySql syntax;


Read the content or code / instruction -

MySQL table schema

understand the mysql table schema and subsequence, very simple straight forward. Here some examples...

  1. AS ... WHERE
  2. SELECT A.fname, B.lname FROM a_database.table_name AS A, b_database.table_name AS B WHERE A.id = B.id;
    the subsequence concept: database.table.column
    AS clause is an alias that to make variable name shorter and read easier: database.table AS A -> A.column
    WHERE A.id = B.id to make more logical.

  3. JOIN ... ON
  4. SELECT A.fname, B.lname FROM a_database.table_name AS A JOIN b_database.table_name AS B ON A.id = B.id;
    JOIN different database.table together
    ON A.id = B.id to make more equally logic.

  5. JOIN ... ON ... WHERE
  6. SELECT A.fname, B.lname FROM a_database.table_name AS A JOIN b_database.table_name AS B ON A.id = B.id WHERE A.join_date > '2013-01-01';
    JOIN different database.table together
    ON A.id = B.id to make more equally logic.
    WHERE is looping the specific data.
    < less than
    > greater than
    = equals to

open the content >>

see the code OR slideshow instruction



//connect the database ....
<?php 
$query
="SELECT A.fname, B.lname FROM a_database.table_name AS A 
JOIN b_database.table_name AS B 
ON A.id = B.id 
WHERE A.join_date > '2013-01-01' AND B.join_date < '2013-01-31'
ORDER BY A.post_date DESC"
;
.........
?>

Watch next videos and relative source page(s)

tag MySQL - php
Programming Web Development Networking FunG project

Topic Discussion:

No Topic Discuss Now...