码迷,mamicode.com
首页 > 数据库 > 详细

【Mysql】select

时间:2014-05-01 06:14:32      阅读:467      评论:0      收藏:0      [点我收藏+]

标签:com   http   style   blog   class   div   img   code   c   java   log   

描述

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

【Mysql】select

标签:com   http   style   blog   class   div   img   code   c   java   log   

原文地址:http://www.cnblogs.com/Susake/p/3702002.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!