0

Need help to update 2 rows in the same table, been searching & testing with no real luck.

I need to update 2 rows based on the URL below... id=145&contactuname=json101&contactid=7&memberid=1&confirm=2 Updating these fields: ustatus, memberid, contactid, contactuname Table structure:

CREATE TABLE `contacts` (
`id` INT(40) NOT NULL AUTO_INCREMENT,
`ustatus` TINYINT(1) NULL DEFAULT '0',
`memberid` INT(20) NOT NULL,
`contactid` INT(20) NOT NULL,
`contactuname` VARCHAR(31) NOT NULL,
`blocked` INT(1) NULL DEFAULT '0',
PRIMARY KEY (`id`)
)

No clue how these work, anyone able to show how my table could work with the queries below?

update table1
set col1 = a.col1, col2 = a.col2, col3 = a.col3 from 
(select col1, col2, col3 from table2 where <expression>) as a
where table1.col1 <expression>
UPDATE Table1
SET (Col1, Col2, Col3, Col4) = 
(SELECT Col1a, Col2a, Col3a, Col4a FROM Table2 WHERE Col5a=Table1.Col5) 
WHERE Col5 IN (SELECT Col5a FROM Table2 )
2
Contributors
3
Replies
4
Views
6 Years
Discussion Span
Last Post by json101
0

try this:

update table1, table2
set table1.col1 = table2.col1, table1.col2 = table2.col2, table1.col3 = table2.col3 where table1.col1 = table2.somefield
0

try this:

update table1, table2
set table1.col1 = table2.col1, table1.col2 = table2.col2, table1.col3 = table2.col3 where table1.col1 = table2.somefield

I'm not sure I understand?
I only have 1 table not 2

0

Why I never saw this... but solved with 2 updates:

$memberid = $_GET['memberid'];
$contactid = $_GET['contactid'];
$id = $_GET['id'];
mysql_query("UPDATE contacts SET blocked='0', status='0'  WHERE id='$id'") or die (mysql_error());
mysql_query("UPDATE contacts SET blocked='0', status='1'  WHERE memberid='$contactid' AND contactid='$memberid'") or die (mysql_error());

Edited by json101: Solved

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.