Dr_Lion Posted February 19, 2014 at 12:30 PM Report #545785 Posted February 19, 2014 at 12:30 PM (edited) Ora bem, tendo uma tabela user do tipo: user ----------------- | id | salario | ----------------- | 1 | 1200 | | 2 | 900 | | 3 | 900 | | 4 | 900 | | 5 | 1000 | | 6 | 1100 | ----------------- O que eu queria fazer era atualizar os salarios com valor apenas de 900 para 1000. $SQL = "UPDATE user SET salario = 1000 WHERE salario = 900"; $result = mysql_query(SQL); Ora bem, eu não tenho a certeza se isto é possível, mas dava-me imenso jeito, já pesquisei na internet e não encontro nada sobre atualizar o mesmo campo da clausula WHERE. Outra dúvida prende-se também, com o fato de existirem 3 linhas para atualizar e não apenas só uma. O UPDATE é capaz de tratar a 3 em simultâneo? Edited February 19, 2014 at 12:31 PM by Dr_Lion
HappyHippyHippo Posted February 19, 2014 at 12:38 PM Report #545786 Posted February 19, 2014 at 12:38 PM e que tal experimentares ? vais ver que estarás a fazer uma tempestade num copo de água ... 2 Report IRC : sim, é algo que ainda existe >> #p@p Portugol Plus
mlcalves Posted February 19, 2014 at 12:46 PM Report #545787 Posted February 19, 2014 at 12:46 PM esse update está certo 🙂
Dr_Lion Posted February 19, 2014 at 12:47 PM Author Report #545788 Posted February 19, 2014 at 12:47 PM Vou confirmar melhor então, é porque eu já experimentei e não resultou.. Mas posso estar a cometer algum erro vindo de trás..
mlcalves Posted February 19, 2014 at 01:06 PM Report #545789 Posted February 19, 2014 at 01:06 PM o nome da tua tabela é user?
Dr_Lion Posted February 19, 2014 at 01:43 PM Author Report #545791 Posted February 19, 2014 at 01:43 PM (edited) Já descobri o erro, tinha um if antes a confirmar uma condição, e a variável estava mal escrita, logo nunca entrava nesse trecho de código e não era feita a atualização. Mas afinal estava tudo a funcionar corretamente. Desde já agradeço toda a ajuda prestada. Edited February 19, 2014 at 01:43 PM by Dr_Lion
taviroquai Posted February 19, 2014 at 01:46 PM Report #545792 Posted February 19, 2014 at 01:46 PM Falta-te ai um cifrao... deve ser mysql_query($SQL).
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now