in reply to Perl/MySQL Problem

I don't like the look of this bit:

active != "0"

isn't it supposed to be "<>" for not equals in SQL?

also, use brackets when you've got complicated ANDs and ORs, it'll help you see it better, like:

SELECT * FROM users WHERE (state = "FL" OR state = "NY") AND (active <> 0)
and are you supposed to be quoting number values?

I've now reached the end of my SQL knowledge, but is there a difference between active=0 and active="0"? If it's the contents of a number-type field?
--

Replies are listed 'Best First'.
Re: Re: Perl/MySQL Problem
by biograd (Friar) on Feb 24, 2002 at 20:40 UTC
    In MySQL, you can use either <> or != interchangeably in the where statement. Ref=pg 253 of MySQL & msql (O'Reilly).

    I have not found that it makes a difference putting quotes around a number or not in my experience, but who's to say I haven't just been lucky?

    -jenn