473,508 Members | 2,143 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Does MySQL have something like x++ or x-- ???


Folks,

I have a table containing addresses. I have a seperate contacts table that
contains peoples names - This allows me to record more than one persons name
related to a single address.

My address table contains a numeric field/value. It counts the number of
people that are related to a single address. I am wondering if there is a
method that, with a single query/statement to my database, that I can
increment/decrement this numeric value in the address table pending if I
have added/removed an entry from the contacts table.

I know in PHP, C++ and some other programming langauges, there is something
like count++ or count-- I am wondering if MySQL can provide a similar
feature as this, or do I have to read the existing value,
increment/decrement it, then re-write it back to the table?

All help, via the newsgroup, much appreciated,
randell d.
Jul 19 '05 #1
4 5336
Reply-Via-Newsgroup wrote:
My address table contains a numeric field/value. It counts the number of
people that are related to a single address. I am wondering if there is a
method that, with a single query/statement to my database, that I can
increment/decrement this numeric value in the address table pending if I
have added/removed an entry from the contacts table.


Perhaps this would do the trick?

# to add
update yourtablename set value = value + 1 where [add conditions here];

# to remove
update yourtablename set value = value - 1 where [add conditions here];
Jul 19 '05 #2
Reply-Via-Newsgroup wrote:
My address table contains a numeric field/value. It counts the number of
people that are related to a single address. I am wondering if there is a
method that, with a single query/statement to my database, that I can
increment/decrement this numeric value in the address table pending if I
have added/removed an entry from the contacts table.


Perhaps this would do the trick?

# to add
update yourtablename set value = value + 1 where [add conditions here];

# to remove
update yourtablename set value = value - 1 where [add conditions here];
Jul 19 '05 #3

"Aggro" <sp**********@yahoo.com> wrote in message
news:Xa***************@read3.inet.fi...
Reply-Via-Newsgroup wrote:
My address table contains a numeric field/value. It counts the number of people that are related to a single address. I am wondering if there is a method that, with a single query/statement to my database, that I can
increment/decrement this numeric value in the address table pending if I
have added/removed an entry from the contacts table.


Perhaps this would do the trick?

# to add
update yourtablename set value = value + 1 where [add conditions here];

# to remove
update yourtablename set value = value - 1 where [add conditions here];


Thanks for the suggestion... I'll try it out over the weekend...

Cheers
randell d.
Jul 19 '05 #4

"Aggro" <sp**********@yahoo.com> wrote in message
news:Xa***************@read3.inet.fi...
Reply-Via-Newsgroup wrote:
My address table contains a numeric field/value. It counts the number of people that are related to a single address. I am wondering if there is a method that, with a single query/statement to my database, that I can
increment/decrement this numeric value in the address table pending if I
have added/removed an entry from the contacts table.


Perhaps this would do the trick?

# to add
update yourtablename set value = value + 1 where [add conditions here];

# to remove
update yourtablename set value = value - 1 where [add conditions here];


Thanks for the suggestion... I'll try it out over the weekend...

Cheers
randell d.
Jul 19 '05 #5

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

Similar topics

2
3917
by: Simon | last post by:
Hi, I am having a little problem with my PHP - MySQl code, I have two tables (shown below) and I am trying populate a template page with data from both. <disclaimer>Now I would like to say my...
2
7934
by: yzzzzz | last post by:
Hi I just upgraded from MySQL 4.0.something to 4.1.1 (alpha). When I try to connect to MySQL in a PHP script, I get the following error: "mysql_connect(): Client does not support...
9
4252
by: Market Mutant | last post by:
PhpNuke is the worse written PHP script as I heared then what does not suck? I need a fast, simple, CMS. I don't need that many hacks. No MySQL is the best. CMS is about news, and forum. I found...
6
1574
by: lawrence | last post by:
I've spent some time going over this page: http://dev.mysql.com/doc/mysql/en/Data_Manipulation.html And so far it seems the answer is no. So I thought I'd ask here. Does anyone know of any...
0
678
by: Miguel Cardenas | last post by:
Hello list For some strange reason `mysql_config --...` does not work. If try something like gcc -o progname `mysql_config --cflags` progname.c `mysql_config --libs` (NOTE:...
0
1702
by: John R | last post by:
I found this old thread while looking for some type of compression solution myself. Long story short, I contacted Lester and ended up writing an LZO solution just as Mark had mentioned below....
175
11198
by: Sai Hertz And Control Systems | last post by:
Dear all, Their was a huge rore about MySQL recently for something in java functions now theirs one more http://www.mysql.com/doc/en/News-5.0.x.html Does this concern anyone. What I...
2
1817
by: PRS | last post by:
Why does 'SELECT * FROM countries' truncate characters and SELECT country FROM countries does not ? mysql> SELECT * FROM countries; +-------------+-----------+ | country | capital |...
5
2846
by: Guillermo Antonio Amaral Bastidas | last post by:
Hi everybody, I have a quick and probably dumb question, keep in mind I just dumped my old love FastCGI + Perl for it's younger hotter friend PHP5. If the user calls a time consuming script...
3
10336
by: moltendorf | last post by:
I copied the files from my "test" database on my old server (MySQL was not running) to my new server ("./mysql/data/test" folder), and after starting the server, SHOW TABLES; shows all of the tables...
0
7326
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,...
0
7385
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
7046
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...
0
7498
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...
0
5629
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
3195
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...
0
1558
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
766
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
418
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.