【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; }
郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。