Jump to content

update query


sandy1028

Recommended Posts

I have two tables in which "id" is constant.

 

Table 1 columns are: id, value_of

 

The value_of column has the values "2010/07/10/name1_abc"

 

Table2 columns are id, key,value_id

 

value_id values are represented as "2010-07-11 00:00:00"

 

Now I have to change the value in table1.

 

select value-of from table1 cv, table2 c where c.id=cv.id and key=28
and c.id=153

 

This will return the value 2010/07/15/lon-abc.

 

Using the query I have check, if the values of "value_of" column and value_id are equal. If it is not equal then, I should not update "value_of".

 

i.e

"value_of" in table1 is "2010/07/10/name1_abc" and value_id is "2010-07-11 00:00:00",

then value_of should be changed to "2010/07/11/name1_abc"

 

if YYYY, MM, DD are same in two tables then I should not update the value or else I have to replace it.

Link to comment
https://forums.phpfreaks.com/topic/208266-update-query/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.