into语句。具体格式:
insert
into
表名(列名1,列名2,...,列名n)values('值1','值2',...,'值n')
或者绑定变量,官网例子:MYSQL_TIME ts
MYSQL_BIND bind[3]
MYSQL_STMT *stmt
strmov(query, "INSERT INTO test_table(date_field, time_field,
timestamp_field) VALUES(?,?,?")
stmt = mysql_stmt_init(mysql)
if (!stmt)
{
fprintf(stderr, " mysql_stmt_init(), out of memory\n")
exit(0)
}
if (mysql_stmt_prepare(mysql, query, strlen(query)))
{
#include <stdio.h>#include <stdlib.h>
#include <mysql/mysql.h>
int main(int argc, char *argv[])
{
MYSQL *my_con = malloc( sizeof(MYSQL) )
MYSQL_RES *my_res
MYSQL_FIELD *my_field
MYSQL_ROW my_row
int rows, i
int res
int a[2] = {51,2}
printf("%3d ",a[0])
mysql_init(my_con)
my_con = mysql_real_connect(my_con, "localhost", "root", "jwn.com",
"jwn", 0, NULL, CLIENT_FOUND_ROWS)
if( NULL == my_con )
error_quit("Connection fail", my_con)
printf("Connection success\n")
res = mysql_query(my_con,
"insert into class1(name, age, birthday) value('abc', 52, NOW())")
mysql_free_result(my_res)
mysql_close(my_con)
free(my_con)
return 0
}
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)