Jump to content
bluestyle

actualizare campuri prin SQL

Recommended Posts

Va salut. Am nevoie de un cod SQL prin care sa pot actualiza campurile "Displayed text when in stock" si "Displayed text when backordering is allowed" ale unui singur furnizor. Ma puteti ajuta?

Edited by bluestyle (see edit history)

Share this post


Link to post
Share on other sites

despre ce furnizor e vorba? (text nume furnizor)

si cel mai bine ar fi sa stii ID al acelui furnizor.

o intrebare colaterala ar fi daca produsele acelui furnizor sunt unice sau mai exista si alti furnizori cu acelasi produs

Share this post


Link to post
Share on other sites

Vom face actualizarea pe baza id-ului furnizorului, cred ca este cel mai bine. Cred ca sunt cateva produse vandute de 2 furnizori, insa asta nu ne incurca cu nimic.

Share this post


Link to post
Share on other sites

pentru Displayed text when in stock

 

update prefix_product_lang set available_now="in stoc"

where id_product in (select id_product from prefix_product_supplier where id_supplier=x)

 

pentru Displayed text when backordering is allowed

 

update prefix_product_lang set available_later="disponibil la comanda"

where id_product in (select id_product from prefix_product_supplier where id_supplier=x)

 

unde "prefix" este prefixul tabelelor din baza de date

si "x" este id-ul acelui furnizor

 

ca sa afli cine e "x" te uiti in tabela prefix_supplier

Share this post


Link to post
Share on other sites

Eu as merge mult mai departe si as adauga un comentariu in functie de stoc-ul existent al produsului + distribuitor.

 

Am atasat si codul ... rugamintea ar fi sa va jucati cu el pe un site de test ca apoi dupa verificari sa il rulati pe live.

 

 

 

 

UPDATE ps_stock_available t1, ps_product t2, ps_product_lang t3, ps_supplier t4
SET t3.available_now=(CASE WHEN t1.quantity='1' THEN 'Stoc Limitat'
WHEN t1.quantity>'1' THEN 'In Stoc' end),
t3.available_later=(CASE WHEN t1.quantity='0' THEN 'Disponibil la Comanda'
WHEN t1.quantity<'0' THEN 'Fara Stoc' end)
WHERE
t1.id_product=t2.id_product AND
t1.id_product=t3.id_product AND 
t2.id_supplier=t4.id_supplier AND
t4.id_supplier='id_supplier'
 
Unde id_supplier se vede din BO Distribuitori.
Edited by lightsb (see edit history)

Share this post


Link to post
Share on other sites

Cam scump modulul doar pentru acest lucru.

Mai sus am adaugat update-ul pentru cele 2 campuri in functie de stoc si distribuitor.

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


×
×
  • Create New...

Important Information

Cookies ensure the smooth running of our services. Using these, you accept the use of cookies. Learn More