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.

The Database Forum


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



Reply
entering same uniqueid?
Old 11-28-2008, 07:45 AM entering same uniqueid?
Banned

Posts: 34
Trades: 0
hiI have a question I can't figure out.lets say I have tblproduct table with autogenerated key on productId , then I have a tblcompany with compid as unique.then a table that links them, called tblall with compid and productId , but when a company adds a product how do I get that productId to be the same as productId in tblall ?
Necaxa is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 11-28-2008, 07:52 AM Re: entering same uniqueid?
chrishirst's Avatar
Missing! presumed drunk.

Posts: 41,517
Name: Chris Hirst
Location: Blackpool. UK
Trades: 0
What database? and if MySQL what engine?
__________________
Chris. ->> Links are advertising NOT optimising!! <<-
A foolish consistency is the hobgoblin of little minds
Thought for today:- I SEO the only industry where all the cowboys are Indians?
chrishirst is offline
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Old 11-28-2008, 12:22 PM Re: entering same uniqueid?
Banned

Posts: 34
Trades: 0
hey, thanks for replyits mysql , MylSAM.
Necaxa is offline
Reply With Quote
View Public Profile
 
Old 11-29-2008, 01:26 PM Re: entering same uniqueid?
chrishirst's Avatar
Missing! presumed drunk.

Posts: 41,517
Name: Chris Hirst
Location: Blackpool. UK
Trades: 0
Well that's a couple of possibilities out straight away

use
INSERT INTO tblall (compid, productId) VALUES(1, last_insert_id() ) ;
immediately after inserting the new product
__________________
Chris. ->> Links are advertising NOT optimising!! <<-
A foolish consistency is the hobgoblin of little minds
Thought for today:- I SEO the only industry where all the cowboys are Indians?
chrishirst is offline
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Old 11-29-2008, 04:06 PM Re: entering same uniqueid?
Banned

Posts: 34
Trades: 0
heymmmmmm, ok does that work even if there a huge amount of inserts per second?thanks for help by the way
Necaxa is offline
Reply With Quote
View Public Profile
 
Old 11-29-2008, 06:35 PM Re: entering same uniqueid?
chrishirst's Avatar
Missing! presumed drunk.

Posts: 41,517
Name: Chris Hirst
Location: Blackpool. UK
Trades: 0
lock the table before the insert

insert the product
LOCK TABLES tblproduct WRITE
run the inserts
UNLOCK TABLES
__________________
Chris. ->> Links are advertising NOT optimising!! <<-
A foolish consistency is the hobgoblin of little minds
Thought for today:- I SEO the only industry where all the cowboys are Indians?
chrishirst is offline
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Old 11-30-2008, 09:16 AM Re: entering same uniqueid?
Novice Talker

Posts: 5
Name: Edy Galantzan
Trades: 0
You must use transactions
__________________
Edy

Web Pro
edygalantzan is offline
Reply With Quote
View Public Profile Visit edygalantzan's homepage!
 
Old 11-30-2008, 09:21 AM Re: entering same uniqueid?
chrishirst's Avatar
Missing! presumed drunk.

Posts: 41,517
Name: Chris Hirst
Location: Blackpool. UK
Trades: 0
Quote:
Originally Posted by Necaxa View Post
hey, thanks for replyits mysql , MylSAM.
Quote:
Originally Posted by edygalantzan View Post
You must use transactions
Transactions are ONLY available on InnoDb and BDB storage engines.
__________________
Chris. ->> Links are advertising NOT optimising!! <<-
A foolish consistency is the hobgoblin of little minds
Thought for today:- I SEO the only industry where all the cowboys are Indians?
chrishirst is offline
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Old 12-02-2008, 02:12 PM Re: entering same uniqueid?
Learning Newbie's Avatar
Defies a Status

Latest Blog Post:
Astounding Republican Paranoia
Posts: 5,662
Name: John Alexander
Trades: 0
What??
__________________

Please login or register to view this content. Registration is FREE


Please login or register to view this content. Registration is FREE
Learning Newbie is offline
Reply With Quote
View Public Profile
 
Old 12-02-2008, 02:54 PM Re: entering same uniqueid?
chrishirst's Avatar
Missing! presumed drunk.

Posts: 41,517
Name: Chris Hirst
Location: Blackpool. UK
Trades: 0


MyISAM is the general purpose fast retrieval storage engine built on IBMs ISAM storage and has never supported transactions.
If transactional processing is needed the InnoDB engine is the one to use. Or move on to PostGre
__________________
Chris. ->> Links are advertising NOT optimising!! <<-
A foolish consistency is the hobgoblin of little minds
Thought for today:- I SEO the only industry where all the cowboys are Indians?
chrishirst is offline
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Old 12-02-2008, 03:12 PM Re: entering same uniqueid?
tripy's Avatar
Do not try this at home!

Posts: 3,621
Name: Thierry
Location: I'm the uber Spaminator !
Trades: 0
Quote:
Originally Posted by Learning Newbie View Post
What??
Mysql John, you remember ?
That db that transforms nulls into empty when you try to insert a null value in a non nullable field.
Or that truncate fields that are too long.

That db that makes me feel dirty when I have to work with.
__________________
Only a biker knows why a dog sticks his head out the window.
tripy is offline
Reply With Quote
View Public Profile Visit tripy's homepage!
 
Reply     « Reply to entering same uniqueid?
 

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.40347 seconds with 12 queries