Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.
Moderator: General Moderators
GeXus
Forum Regular
Posts: 631 Joined: Sat Mar 11, 2006 8:59 am
Post
by GeXus » Mon Aug 21, 2006 8:25 pm
Is there a way in mysql to check if a record exists and if so, then do an update, if not, do an insert statement.
feyd
Neighborhood Spidermoddy
Posts: 31559 Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA
Post
by feyd » Mon Aug 21, 2006 8:26 pm
GeXus
Forum Regular
Posts: 631 Joined: Sat Mar 11, 2006 8:59 am
Post
by GeXus » Mon Aug 21, 2006 8:34 pm
Wicked.. thanks!
GeXus
Forum Regular
Posts: 631 Joined: Sat Mar 11, 2006 8:59 am
Post
by GeXus » Mon Aug 21, 2006 9:51 pm
This actually does not seem to work.. I probably did not explain well, or maybe I did the replace wrong...
table: favorites
columns:
user_id
fav_1
fav_1_desc
fav_2
fav_2_desc
fav_3
fav_3_desc
It's posible that the fields could be either empty or not.
GeXus
Forum Regular
Posts: 631 Joined: Sat Mar 11, 2006 8:59 am
Post
by GeXus » Mon Aug 21, 2006 9:54 pm
Ok, I think i figured out what ill do.. basically I can always insert one row for the user_id, without any data, then just do updates to the null columns.