0
我在MySQL查詢,做一些認證檢查,但它是相當長的。我想知道是否會有另一種方法來縮短/簡化它,但實際上所有的子句都是必需的。是否有更簡單的方法來編寫此查詢?
select nickname from nicknames where nickname = '$nick' and password = '$md5pass'
union
select '$nick' as nickname from nicknames AS t1 where not
(nickname = '$nick' and password = '$md5pass')
and not exists
(select 1 from nicknames where nickname = '$nick')
這不起作用一樣。當沒有提供密碼但是暱稱存在時,它會返回一行。 – user5603796