MySQL Forums
Forum List  »  InnoDB

INSERT if NOT EXISTS Help??
Posted by: Brian Coleman
Date: September 03, 2008 07:55PM

I have a site that upon signup inserts some info into tables. Then once logged in, more info gets inserted into different tables. So what I need to do is for the second insert, check if it exists, if so UPDATE, if not INSERT. I am new to this so not sure exactly the best most efficient way to do this. Here is my SQL, any help is greatly appreciated.

When a user signs up, member_info gets updated, along with profile_info. When a user logs in, they can update info in 2009_lacrosse. But if an entry with their username and email does not exist, i need to do the Insert if NOT EXISTS.

This is my SQL that gets the record if it exists:

$sql = "SELECT * FROM member_info, 2009_lacrosse, profile_info WHERE member_info.username='$id' AND 2009_lacrosse.username='$id' AND profile_info.username='$id';";

THANKS SO MUCH IN ADVANCE!!!
Brian Coleman

Options: ReplyQuote


Subject
Views
Written By
Posted
INSERT if NOT EXISTS Help??
7779
September 03, 2008 07:55PM


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.