473,569 Members | 2,422 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 5345
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**********@y ahoo.com> wrote in message
news:Xa******** *******@read3.i net.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**********@y ahoo.com> wrote in message
news:Xa******** *******@read3.i net.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
3927
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 skills, especially with MySQL are rudimentary</disclaimer> However my code (link below) fails, the nested database call does not return any data and...
2
7939
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 authentication protocol requested by server; consider upgrading MySQL client in file.php on line 130"
9
4258
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 something called txtForum and simpleboard both are not MySQL based. I assume the forum is the most MySQL consuming application. News can just be put...
6
1578
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 built-in search algorithms with MySql? I'm looking for a way to return the results of my last SELECT statement (which uses LIKE) based on the number...
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: "/usr/local/mysql/bin" is in the PATH var, mysql_config works when invoked)
0
1711
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. Thought this could also benifit someone out there so I'm reposting. Here's a link to the source code: http://www.servangle.net/udf_lzo/ BTW, Lester...
175
11265
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 think is PostgreSQL would have less USP's (Uniqe Selling Points
2
1821
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 | +-------------+-----------+ |ghanistan | Kabul |lbania | Tirane
5
2849
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 and then stops or refreshes the browser before the script had time to finish will Apache kill the script mid execution or will it let it finish ? I...
3
10342
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 that are supposed to be there, but running a SELECT * FROM `configuration`; (for example) returns "test.configuration does not exist). I've tried...
0
7703
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...
0
7926
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. ...
1
7678
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...
0
7982
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...
0
6286
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
0
3644
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2116
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 we have to send another system
1
1226
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
944
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 can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.