MySQL Forums
Forum List  »  Newbie

INSERT questions
Posted by: Alex
Date: September 08, 2004 01:30PM

2 questions:

Assuming you have a table:

CREATE TABLE `global` (
`id` int(11) unsigned NOT NULL auto_increment,
`name` varchar(64) NOT NULL default '',
`value` text,
PRIMARY KEY (`id`)
) TYPE=MyISAM;

1. I want to insert a new row using:

INSERT INTO global (name, value) VALUES ('name','value');

id will be set automatically, but is there any way to get the id used in the insert without having to do a complex SELECT (like SELECT id from global where name='name' and 'value='value')


2. Is there a way to do an UPDATE when a row exists, if not INSERT without having to do a SELECT first?


Thanks.

Options: ReplyQuote


Subject
Written By
Posted
INSERT questions
September 08, 2004 01:30PM
September 08, 2004 05:49PM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.