update 表A,表B,表C set 表C.startd=表A.startd, 表C.startt=表A.startt, 表C.BSC=表A.BSC, 表C.LAC=表A.LAC, 表C.CI=表A.CI, 表C. LAC_ADJ =表A. LAC_ADJ , 表C.CI_ADJ =表A.CI_ADJ where 表A.CI=表B.CI
update 表A,表B,表C set 表C.name=表B.name where 表A.CI=表B.CI
update 表A,表B,表C set 表C.NAME_ADJ=表A.NAME_ADJ where 表A.CI_ADJ=表B.CI
如果表比较大话,表A的CI CI_ADJ和表B的CI加上索引,这样快一些
应该是可以建表的,没有理由只能用手动建表。
Here is an extract.....
I hope it helps.
please remember....u need to compile it with
-lmysqlclient -lz options.
#include <string.h>
#include <stdio.h>
#include "/usr/include/mysql/mysql.h"
MYSQL imysql
MYSQL_RES * mydata
unsigned int num_fields
unsigned int num_rows
unsigned long *lengths
MYSQL_ROW row,
MYSQL_FIELD *fields
char a[241]=""
char querystring[241]=""
void mysqlinit(char user[20], char password[20], char db[20])
void main()
{
mysqlinit("username","userpassword","database")
a[0] ='\0'
strcat(a,"Create Table ")
strcat(a,tablename)
strcat(a,"(pepsi bigint Not Null Primary,coke bigint Not Null)")
printf(a)
strcpy(querystring,a)
if (!mysql_real_query(&imysql,querystring,strlen(querystring)))
{mydata = mysql_store_result(&imysql) }
else
{ printf("Oops ! Error %d:
%s\n",mysql_errno(&imysql),mysql_error(&imysql))
mysql_close(&imysql)
exit(0)
}
mysql_close(&imysql)
}
void mysqlinit(char user[20], char password[20], char db[20])
{
mysql_init(&imysql)
mysql_options(&imysql,MYSQL_READ_DEFAULT_GROUP,"your_prog_name")
if (!mysql_real_connect(&imysql,"",user,password,db,0,NULL,0))
{
fprintf(stderr,"FAILED !!!! Error %s\n",mysql_error(&imysql))
}
else
{
printf( "Connection with Database established !\n")
}
}
给你个参考例子吧。#include <stdio.h>
#include <stdlib.h>
#include <stdarg.h>
#include "mysql.h"
MYSQL *mysql
MYSQL_RES *results
MYSQL_ROW record
static char *server_options[] = { "mysql_test", "--defaults-file=my.cnf" }
int num_elements = sizeof(server_options)/ sizeof(char *)
static char *server_groups[] = { "libmysqld_server", "libmysqld_client" }
int main(void)
{
mysql_server_init(num_elements, server_options, server_groups)
mysql = mysql_init(NULL)
mysql_options(mysql, MYSQL_READ_DEFAULT_GROUP, "libmysqld_client")
mysql_options(mysql, MYSQL_OPT_USE_EMBEDDED_CONNECTION, NULL)
mysql_real_connect(mysql, NULL,NULL,NULL, "database1", 0,NULL,0)
mysql_query(mysql, "SELECT column1, column2 FROM table1")
results = mysql_store_result(mysql)
while((record = mysql_fetch_row(results))) {
printf("%s - %s \n", record[0], record[1])
}
mysql_free_result(results)
mysql_close(mysql)
mysql_server_end()
return 0
}
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)