I have a joined update query as below...
UPDATE items,month SET items.price=month.price
WHERE items.id=month.id;
if price value has '?' in it then I just want to skip updating the record. How do I do it ?
| SitePoint Sponsor |


I have a joined update query as below...
UPDATE items,month SET items.price=month.price
WHERE items.id=month.id;
if price value has '?' in it then I just want to skip updating the record. How do I do it ?
UPDATE items,month
SET items.price=month.price
WHERE items.id=month.id
and month.price<>'?';


No. This will not work.
because Price field value could be like this ...
430-29?8-9 //don't update because it has '?'
4?-0-29?8-9 //don't update because it has '?'
?-29?8-? //don't update because it has '?'
127-65-34 //update it because it does not have '?'
In simple words if the price field value has a "?" in it then just skip this record ...don't update.
How this can be done ?
in this case. In you original post you said...
UPDATE items,month
SET items.price=month.price
WHERE items.id=month.id
and month.price not like '%?%';

I try to always approach a non-select statement as a select statement at first, and then convert it over once you have ensured your going to be affecting the rows that you want.
<?php//Kyle Wolfeecho devBlog("My Dev Notes");
Bookmarks