Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
[MySQL] Inserting a number
Old 09-21-2005, 06:36 PM [MySQL] Inserting a number
HitRaj47's Avatar
Extreme Talker

Posts: 177
Location: GA
Trades: 0
I have a column named 'order' in a table. The data type is "INT". I want to be able to insert a number. The number must be 1 more than the highest number in the column.

I can't do an auto_increment because that's already being used on another column (the primary key).

So I need a way to find out what the highest number is and add 1 to that number and just assign it to a variable, NOT modify the value in mysql.

Hope you can understand that. Thanks.
HitRaj47 is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 09-22-2005, 02:20 AM
chrishirst's Avatar
Missing! presumed drunk.

Posts: 42,385
Name: Chris Hirst
Location: Blackpool. UK
Trades: 0
"SELECT MAX(column) FROM table"

then increment it in php
__________________
Chris. ->>
Please login or register to view this content. Registration is FREE
<<-

A foolish consistency is the hobgoblin of little minds
Thought for today:- Is SEO the only industry where all the cowboys are Indians?
chrishirst is offline
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Old 09-22-2005, 02:52 PM
HitRaj47's Avatar
Extreme Talker

Posts: 177
Location: GA
Trades: 0
OK, thanks a lot, I will go try that now.
HitRaj47 is offline
Reply With Quote
View Public Profile
 
Old 09-22-2005, 08:35 PM
0beron's Avatar
Defies a Status

Posts: 1,832
Location: Somewhere else entirely
Trades: 0
If you get lots of traffic, would it be possible to get a collision between two queries? Ie if one query starts and finds the column max, then another does the same, they both get the same value, both increment it to the same value, and then both write entries in the database with the same number?
__________________
UPDATE 0beron SET talkupation = talkupation + lots WHERE post = 'helpful';

Please login or register to view this content. Registration is FREE
(aka MSN handwriting for forums)
0beron is offline
Reply With Quote
View Public Profile Visit 0beron's homepage!
 
Old 09-23-2005, 05:59 PM
HitRaj47's Avatar
Extreme Talker

Posts: 177
Location: GA
Trades: 0
its actually part of an admin section thingy i am working on for a website. i think there will only be 3 admins and i dont think they will all be working on the same thing at the same time.

so, i dont see that as a problem.
HitRaj47 is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to [MySQL] Inserting a number
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.15799 seconds with 12 queries