Jump to content

INSERT and SELECT in the same query?


pizzaguy
 Share

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.

Edited by Pizzaguy
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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...