You could use a stored procedure to do the INSERT and then return the
value from SELECT statement. For example,
DELIMITER $$;
DROP PROCEDURE IF EXISTS `test`.`spINSERTandSELECT`$$
CREATE PROCEDURE `test`.`spINSERTandSELECT` (IN strFirstName
VARCHAR(20),
IN strLastName VARCHAR(20))
BEGIN
INSERT INTO
usernames (FirstName, LastName)
VALUES
(strFirstName, strLastName);
SELECT CONCAT(strFirstName, " ", strLastName);
END$$
DELIMITER ;$$
Then call the stored procedure as follows:
mysql> use test;
Database changed
mysql> call spINSERTandSELECT("John", "Doe");
+----------------------------------------+
| CONCAT(strFirstName, " ", strLastName) |
+----------------------------------------+
| John Doe |
+----------------------------------------+
1 row in set (0.06 sec)
Query OK, 0 rows affected (0.06 sec)
mysql>
Hope this helps.
Randall Price
Microsoft Implementation Group
Secure Enterprise Computing Initiatives
Virginia Tech Information Technology
1700 Pratt Drive
Blacksburg, VA 24060
Email: [EMAIL PROTECTED]
Phone: (540) 231-4396
-----Original Message-----
From: Deckard [mailto:[EMAIL PROTECTED]
Sent: Tuesday, October 03, 2006 11:40 AM
To: [email protected]
Subject: Returning value after insert
Hi,
Is there a way of after a select statement having a return value for a
determined field ?
For example, after this:
INSERT INTO wl_users(name, email, password) VALUES('Deckard',
'[EMAIL PROTECTED]', 'blabla')
having the name returning without having to make a subsequent select.
Any help would be appreciated.
Best Regards,
Deckard
--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:
http://lists.mysql.com/[EMAIL PROTECTED]
--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe: http://lists.mysql.com/[EMAIL PROTECTED]