Thursday, May 31, 2012

mysql advance query


copy one row to insert into the same table?

INSERT INTO table (col1, col2, col3, ...)
SELECT col1, col2, col3, ... FROM table


Fetch from one table and insert into another table single query

INSERT INTO table (col1, col2, col3, ...)
SELECT col1, col2, col3, ... FROM table2


Fetch from one table a database and insert into another table another database single query single query

INSERT INTO database1.table (col1, col2, col3, ...)
SELECT col1, col2, col3, ... FROM database2.table



How do you connect to multiple MySQL databases on a single webpage?


You can make multiple calls to mysql_connect(), but if the parameters are the same you need to pass true for the '$new_link' (fourth) parameter, otherwise the same connection is reused.
so then you have
$dbh1 = mysql_connect($hostname, $username, $password); 

$dbh2 = mysql_connect($hostname, $username, $password, true); 



mysql_select_db('database1', $dbh1);

mysql_select_db('database2', $dbh2);



Then to query database 1, do
mysql_query('select * from tablename', $dbh1);



and for database 2
mysql_query('select * from tablename', $dbh2);

select with select in where clause

select * from value where id in (select id from value where id=1000000); 

A web hosting service allows individuals and organizations to make their website accessible via the World Wide Web. Web hosts are companies that provide space on a server which is connected by internet. It can be owned or leased as per need there are many cheap webhosting companies
You can create own hosting company at your home using static IP and internet.
The host may also provide an interface or control panel for managing the Web server and installing scripts, as well as other modules and service applications like e-mail. Some hosts specialize in certain software or services like e-commerce, which are commonly used by larger companies that outsource network infrastructure.

Many webhosting companies provide ftp userid and password with help of this you can upload your file and webpage on your server, many companies provide free ftp software.

FileZilla id famous between users you can download it here- The free FTP solution



Types of hosting
Internet hosting services can run Web servers.
§  Shared web hosting service
§  Reseller web hosting
§  Virtual Dedicated Server
§  Dedicated hosting service
§  Managed hosting service
§  Collocation web hosting service
§  Cloud hosting
§  Clustered hosting
§  Grid hosting
§  Home server
Some specific types of hosting provided by web host service providers:
§  File hosting service: hosts files, not web pages
§  Image hosting service
§  Video hosting service
§  Blog hosting service
§  Paste bin
§  Shopping cart software

Tuesday, May 29, 2012

How do you connect to multiple MySQL databases on a same webpage?


below i tell you ,How you connect to multiple MySQL databases on a same webpage?
$hostname='localhost';
$username='username';
$password='password';
$dbname='database1';
$hostname2='localhost';
$username2='username';
$password2='password';
$dbname2='database2';


$dbh1 = mysql_connect($hostname, $username, $password); 
$dbh2 = mysql_connect($hostname2, $username2, $password2); 

mysql_select_db('database1', $dbh1);
mysql_select_db('database2', $dbh2);
Then to query database 1, do
mysql_query('select * from tablename', $dbh1);
and for database 2
mysql_query('select * from tablename', $dbh2);