SQL选择和插入 [英] SQL SELECT AND INSERT

查看:89
本文介绍了SQL选择和插入的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当您运行mysql的Select语句时,然后您运行了Insert语句,您必须在Select语句之后执行一些操作才能使Insert语句起作用.插入可以单独工作,但在遵循Select语句时则不能工作.它们都在同一个数据库中.

When you run an mysql Select statement, then you you run an Insert statement, do you have to do something after the Select statement to have the Insert statement work. The Insert works on its own but not when it follows the Select statement. They are both on the same database.

MYSQL_RES *res_set;
MYSQL* conn;
MYSQL_ROW LEGIT;
MYSQL_ROW MX;
MYSQL_ROW TTL;
MYSQL mysql;
MYSQL_RES res;
MYSQL_ROW row;
conn = mysql_init(NULL);

     
if (mysql_real_connect(conn,"urlock.db.5513143.hostedresource.com","VendorCheck","Reader1234","urlock",0,NULL,0) !=0)
	{
		mysql_query(conn,"SELECT COUNT(*) FROM tblURL WHERE IP = ''192.168.1.1'' And Status = ''Active''");
		my_ulonglong i = 0;
		res_set = mysql_store_result(conn);
		my_ulonglong numrows = mysql_num_rows(res_set);
		LEGIT = mysql_fetch_row(res_set);
		if (atoi(LEGIT[i]) == 1)
		{
			//printf("PASS: %s\n",LEGIT[i]);
			
						(mysql_real_connect(conn,"urlock.db.5513143.hostedresource.com","urlock","Admin1234","urlock",0,NULL,0) !=0);
			(mysql_query(conn,"SELECT (Max) FROM tblURL WHERE IP = ''192.168.1.1'' And Status = ''Active''"));
				my_ulonglong h = 0;
				res_set = mysql_store_result(conn);
				MX = mysql_fetch_row(res_set);
				//printf("Max Allowed: %s\n",MX[h]);
			
			
			(mysql_real_connect(conn,"urlock.db.5513143.hostedresource.com","urlock","Admin1234","urlock",0,NULL,0) !=0);
			(mysql_query(conn,"SELECT COUNT(*) FROM tblURLAccess WHERE IP = ''192.168.1.1'' And Dwnload = ''1''"));
				my_ulonglong g = 0;
				res_set = mysql_store_result(conn);
				my_ulonglong numrows = mysql_num_rows(res_set);
				TTL = mysql_fetch_row(res_set);
				/* clean up */
				mysql_free_result(res_set);
				mysql_close(&mysql);

推荐答案

我在您的代码中看不到任何插入,但是如果您的意思是它没有出现在您的数据中,已经检索到,直到您再次选择它.将其添加到数据库不会将其添加到数据的本地副本.
I don''t see any inserts in your code but if what you mean is that it doesn''t show up in the data you''ve already retrieved, it won''t until you select it again. Adding it to the database won''t add it to your local copy of the data.


以下链接可能有帮助:-

http://www.freebsddiary.org/mysql-capi.php [
The followings link may be of some helpf: -

http://www.freebsddiary.org/mysql-capi.php[^]

Let me know if this was helpful

--
AJ


这篇关于SQL选择和插入的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆