Replace Info in a single cell! --> I'm almost giving up!

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
ykarmi
Forum Commoner
Posts: 35
Joined: Mon Oct 30, 2006 4:45 pm

Replace Info in a single cell! --> I'm almost giving up!

Post by ykarmi »

I searched and searched and read the W3Schools tutorials, fluffycat.com tutorials, different references and mainly Google (*ahm* Ole *ahm* :wink:) but I just COULDN'T FIND AN ANSWER!!! :roll: - how to replace information in a single cell?
What bothers me the most, is that INSERT doesn't have a WHERE to it, unlike SELECT.
I'm not even sure whether INSERT can replace data or not. I have a cell, that already contains data, but now I want to replace that data with new one, but when I tried to access one cell, I found out the the most you can do is access the whole row. I don't want to change the whole - I have 28 values in it!!!

How can I replace information in only one cell - preferably using PHP??? It's killing me!!!
Please don't jump on me saying I'm just posting, Iv'e been searching for the past 3 hours for a solution just so you guys don't yell at me for not trying :wink:

Thank you soooooooo much,
Yuval
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

an UPDATE query.
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post by volka »

User avatar
Ollie Saunders
DevNet Master
Posts: 3179
Joined: Tue May 24, 2005 6:01 pm
Location: UK

Post by Ollie Saunders »

OK I'm just going to give it to you now:

Code: Select all

-- Change the value
UPDATE `table` SET `column` = 'new_value' WHERE `tablePrimaryKey` = 1

Code: Select all

-- Create it in the first place
INSERT INTO `table` VALUES (`... all the columns specified in order here`

Code: Select all

$q = 'SELECT `column` FROM `table` WHERE `tablePrimaryKey` = 1';
$result = mysql_query($q) or die('Query error');
$row = mysql_fetch_assoc($result);
echo $row['column'];
Post back if you are still having difficulties with your database schema.
ykarmi
Forum Commoner
Posts: 35
Joined: Mon Oct 30, 2006 4:45 pm

Ohhhhhh

Post by ykarmi »

Ohhhhhhhhhhh, So you can't select the cell right away?
You have to get the row, then select the cell out of the row?
I'll definitely give it a try and let you know how it worked.
Thank you sooooooo much! :P :P :P
Yuval :D
User avatar
Ollie Saunders
DevNet Master
Posts: 3179
Joined: Tue May 24, 2005 6:01 pm
Location: UK

Post by Ollie Saunders »

I could almost hear the click from your brain as it all suddenly made sense :D
Post Reply