php mysql check existing syntax -
i have ordering system 1 6 (both inclusive), order number assigned news in table featured user's choice. when user saves order news, in table featured inserted new row these fields: id_news, id_user, id_category , order
what looking better syntax check if there news client x order y.
right i'm doing each thing in separate query, these actions:
- user chooses feature news 1241 order number 3
- script checks see if there exists news client
xorder number 3 - if exists, deletes it
- add new featured news.
anyway of making in less actions/code?
use on duplicate key update.
assuming (id_user,order) unique key, can insert new value and, if order exists, update new id_news.
insert `featured` values (...) on duplicate key update `id_news`=values(`id_news`)
Comments
Post a Comment