這裏是我當前的查詢如何使用if/else語句在UPDATE語句
UPDATE `records` SET tester1 = '$user', tester1yn = '$pass'
我想什麼來改變這是
UPDATE `records` SET
IF `tester1` IS NULL `tester1` = $user, AND `test1` = $pass
ELSE `tester2` = $user, `tester1yn` = '$pass'
WHERE `id` = $id
但正如我有這不起作用。我有一個嵌套的問題,或者我正在做這個錯誤的方式?
UPDATE意見的基礎上
UDPATE records SET
tester1 = if(tester1 IS NULL,'$user',tester1),
tester1yn = if(tester1 is null, '$pass', tester1yn),
tester2 = IF(tester1 is not null, '$user', tester2),
tester2yn = IF(tester1 is not null,'$pass', tester2yn)
where id = $id
仍然還沒有實現,但。
編程_guessing_不起作用。閱讀MySQL文檔以瞭解其功能。請注意,查詢是單個聲明性語句,而不是過程函數。 – 2013-05-01 20:00:13
可能重複的[MYSQL IF ELSE語句在查詢?](http://stackoverflow.com/questions/8763310/mysql-if-else-statement-in-query) – 2013-05-01 20:00:31
這是一個經典的MySQL注入示例,請參閱:http://stackoverflow.com/questions/60174/how-to-prevent-sql-injection-in-php – 2013-05-01 20:01:06