473,657 Members | 2,490 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Rows affected?

Hi,

I am executing an update-query. Is there a way I would get a result if there
is a row affected, because if the row isn't affected (product may not exist)
I have to execute a insert-query. This way I could use 1 query (in the
update-case). Else I would always have to execute 2 query's (1 count-query
and 1 insert or update query).

Thnxz...
Jul 16 '05 #1
2 3184
no spam wrote:
Hi,

I am executing an update-query. Is there a way I would get a result if
there is a row affected, because if the row isn't affected (product may
not exist) I have to execute a insert-query. This way I could use 1 query
(in the update-case). Else I would always have to execute 2 query's (1
count-query and 1 insert or update query).

Thnxz...


http://dk.php.net/manual/en/function...ected-rows.php

Should give you a hint.
That it says dk.php.net is only due to the local mirror.

/Andreas
--
Registeret Linux user #292411
Jul 16 '05 #2
thnxz... mysql_affected_ rows() was the function. Totally forgot the
mysql-functions...

"Eivind Lie Nitter" <el*@gmx.net> schreef in bericht
news:1fz4bvf.ic k75z156nw93N%el *@gmx.net...
Roger Godefroy <godefroy@(nosp am)home.nl> wrote:
Hi,

I am executing an update-query. Is there a way I would get a result if there is a row affected, because if the row isn't affected (product may not exist) I have to execute a insert-query. This way I could use 1 query (in the
update-case). Else I would always have to execute 2 query's (1 count-query and 1 insert or update query).

Thnxz...


If you are using MySQL:

mysql_query("up date table set bla='bla' where id=17");

if (mysql_affected _rows() == 0) {

mysql_query("in sert ...");

}

Should work :)

--
Eivind Lie Nitter
el*@gmx.net
http://ununique.net

Jul 16 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
33297
by: RotterdamStudents | last post by:
Hello there, i have a strange problem. I can't get php to insert multiple rows at once in a MySQL database. I use the $sql = "INSERT INTO database (a,b,c,d,e) VALUES ('$a', '$b' ,'$c', '$d', '$e')"; I want to insert 5 rows at a time in the database, but it only inserts every 5th record. For example: 1. AA
5
5080
by: Chris Stromberger | last post by:
When issuing updates in mysql (in the console window), mysql will tell you if any rows matched and how many rows were updated (see below). I know how to get number of rows udpated using MySQLdb, but is there any way to get the number of rows matched? I want to find out, when rows updated = 0, if there were no updates because the row wasn't found (rows matched will = 0) or because the update would not have changed any data (rows matched =...
2
9909
by: Gnurp Gnarp | last post by:
When the number of columns get large, it becomes increasingly difficult to view the results of a select in a small window (e.g. 80 line xterm) because of line wrapping. Can I have the results of the select query displayed rotated, e.g. like this: +------+------+------+------+ | | row0 | row1 | row2 | +------+------+------+------+ | col0 | 0 | 3 | 6 | | col1 | 1 | 4 | 7 |
1
1592
by: dkode8 | last post by:
Heres my problem, the first part selects a row from the database, if there is no row with the criteria it inserts a row and then returns it, the problem is the IF statement that inserts the row, never returns the select after it. if there is a row initially in the database, it returns the right information, I just can't get it to return the row after inserting it. Anyone know what the problem could be? Stored procedure: ALTER...
2
4305
by: Kiki | last post by:
Hi, just a small question. I've just looked at a friends code and he's done this: int rowsAffected = sql.ExecuteNonQuery("stored_procedure", cmdParams); if(rowsAffected < 1) { return false; } else {.......
4
7056
by: kenfar | last post by:
I've got a batch etl process in which I typically wrap DML with selects in order to capture the number of rows affected. For example: SELECT 'rows updated', COUNT(*) FROM NEW TABLE ( UPDATE stage_asset SET ip_int = ip_to_bigint(ip_string) WHERE ip_int IS NULL ) How can I do this for a merge? For example:
3
15966
by: Carl K | last post by:
using MySQLdb, I do cursor.execute("update...") How can I tell how many rows were affected ? Carl K
3
3026
by: senthilnova | last post by:
hi all i have c# class which calls a stored procedure having insert,update and delete method (using if to switch between them). when i call the SP to EXECUTENONQUER() there is no response from the sqlserver. I too tested the stored proc seperately , it shows NO ROWS AFFECTED and 0 ROWS RETURNED. But the rows get inserted , or updated according to my call.(i found this by checking recs in table).what would be the trouble?? really confusing...
0
1309
by: shashi shekhar singh | last post by:
Respected Sir, i want to check it out, when insert returns zero rows affected ? insert into Question_Copy(,column_name1,column_name2,column_name3) SELECT top 1 column_name1,column_name2,column_name3 FROM tablename where column_name1 not in (select column_name1 from Question_Copy) --and column_name2 not in (select column_name2 from Question_Copy) and UNIT_CODE not in (select UNIT_CODE from Question_Copy) --and column_name3...
0
8392
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8305
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8823
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
8503
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8603
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6163
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5632
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4151
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4301
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.