首页 > 代码库 > 【Mysql】select
【Mysql】select
描述
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;
下面是测试代码
#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; }
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。