Jump to content

INSERT and SELECT in the same query?


pizzaguy

Recommended Posts

For a user registration page I'm making, I have this query to insert the new user's information into the database

INSERT INTO users (email,password,public_url,first_name,last_name) VALUES ('$email','$encypted','$URL','$firstName','$lastName') LIMIT 1;

Is it possible to also have the query response either return the whole row, or act as though I'm also including "SELECT uid"? Basically, "uid" is my auto_incrementing value, and I want to know if it's possible to access this without having to perform a separate SQL query? It just seems redundant to insert values, and then search for those values again.

Link to comment
Share on other sites

I suppose you could just test the value of the query after you execute it, and if it was successful, just reuse the same values you just inserted.Other than that, depending on the database, you might be able to use stored procedures and have it return the record.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...