Visualizzazione dei risultati da 1 a 7 su 7
  1. #1

    [MySQL] operazioni tra un campo ed una variabile in una UPDATE

    Una sintassi del genere è accettabile?
    codice:
    $sold=2;
    $query="UPDATE ut SET euro='euro*$sold' WHERE id=id.ut";
    GdR Online - http://lenar.it/
    Yesterday is history. Tomorrow is mystery.
    Today is a gift. That's why it's called the present

  2. #2

  3. #3
    Cioé, non devo per forza fare una SELECT del campo, moltiplicarla per la variabile e poi creare l'UPDATE...ho provato ma mi sa che non gira...forse problemi con le "" e ''
    GdR Online - http://lenar.it/
    Yesterday is history. Tomorrow is mystery.
    Today is a gift. That's why it's called the present

  4. #4
    no, puoi fare l'operazione direttamente nell'update.

  5. #5
    Utente di HTML.it L'avatar di chris
    Registrato dal
    Sep 1999
    Messaggi
    1,568
    Originariamente inviato da Vre
    Cioé, non devo per forza fare una SELECT del campo, moltiplicarla per la variabile e poi creare l'UPDATE...ho provato ma mi sa che non gira...forse problemi con le "" e ''
    penso tu debba eliminare gli apici singoli intorno all'operazione
    SET euro=euro*$sold
    "Nei prossimi tre anni col mio governo vogliamo vincere anche il cancro, che colpisce ogni anno 250.000 italiani e riguarda quasi due milioni di nostri concittadini"

  6. #6
    Non funziona...
    qualche parentesi...boh, se metto un numero invece di una variabile gira bene.
    GdR Online - http://lenar.it/
    Yesterday is history. Tomorrow is mystery.
    Today is a gift. That's why it's called the present

  7. #7
    Funziona!!

    $query="UPDATE ut SET euro=(euro*$sold) WHERE id=id.ut";
    GdR Online - http://lenar.it/
    Yesterday is history. Tomorrow is mystery.
    Today is a gift. That's why it's called the present

Permessi di invio

  • Non puoi inserire discussioni
  • Non puoi inserire repliche
  • Non puoi inserire allegati
  • Non puoi modificare i tuoi messaggi
  •  
Powered by vBulletin® Version 4.2.1
Copyright © 2025 vBulletin Solutions, Inc. All rights reserved.