MYSQL reads data from a database table cyclically and writes data to tables in other databases.

Source: Internet
Author: User
MYSQL reads data from a database table and cyclically writes data to the table of another database. MYSQL reads data from a database table & nbsp; cyclically writes data to the table of another database & nbsp; no error is reported in the code. the code can be read and tested, and data cannot be written. Read data from the table & nbs MYSQL of the TEST database from a database table and write data into the table of another database cyclically.
MYSQL reads data from a database table cyclically and writes data to the table of another database.


No error is reported in the code. the code can be read and tested, and data cannot be written.

Read data from the table content in the TEST Database
$ Conn = mysql_connect ('localhost', 'root ','');
Mysql_select_db ('test ');
Mysql_query ("set names utf8 ");
$ Duqu = "SELECT * FROM 'content' order by rand () LIMIT 0, 10 ";
$ Result = mysql_query ($ duqu, $ conn );


Start to write cyclically to the gzw_arctiny table of the database
For ($ count = 0; $ count <10; $ count ++)
{

Mysql_select_db ('dedecmsv57utf8sp1 ');

$ Xieru = "insert into gzw_arctiny ('id', 'typeid', 'channel', 'senddate', 'sortrank', 'mid ', 'addurl ') values ('', '3', '1', '123', '123', '1', '123 ')";
Mysql_query ($ xieru, $ conn); mysql database insert
------ Solution --------------------
Insert into gzw_arctiny ('id', 'typeid', 'channel', 'senddate', 'sortrank', 'mid ', 'addurl') values...
How can you correctly enclose the field names in single quotes?
------ Solution --------------------
For tables in another database, use another connection string to connect to the database.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.