【Mysql】select

时间:2014-05-01 06:14:32   收藏:0   阅读:467

描述

The SELECT statement is used to select data from a database.

The result is stored in a result table, called the result-set.

大意:select用来从数据库中挑选数据

有以下两种形式

SELECT column_name,column_name
FROM table_name;

SELECT * FROM table_name;

下面是测试代码

bubuko.com,布布扣
#include <WinSock2.h>
#include <stdio.h>
#include <mysql.h>
#pragma comment(lib, "libmysql.lib")

int main(int argc, char *argv[])
{
    MYSQL mysql;
    MYSQL_RES *res;
    MYSQL_ROW row;

    mysql_init(&mysql);

    if (mysql_real_connect(&mysql, "localhost", "root", "Susake", "Susake", 0, NULL, 0))
        printf("数据库连接成功\n");

    mysql_query(&mysql, "insert into Ran(a, b) values(1, 2);");

    mysql_real_query(&mysql, "select *from Ran;", strlen("select *from Ran;"));

    res = mysql_store_result(&mysql);

    while (row = mysql_fetch_row(res))
        printf("%s %s\n", row[0], row[1]);
    return 0;
}
bubuko.com,布布扣

 

【Mysql】select,布布扣,bubuko.com

评论(0
© 2014 mamicode.com 版权所有 京ICP备13008772号-2  联系我们:gaon5@hotmail.com
迷上了代码!