I'm putting this discussion back in the mailing list where it belongs; that way other people can contribute suggestions and learn from the discussion, either now or in the future via the archives.

--

Is there any possibility the Update is doing exactly what your SQL is telling it to do? You're asking for a row to be updated if _any_ of the following are true:
- the subscribe column is not blank
- the artist column contains 1
- the rank_change column does not contain 1

If at least one of those conditions is true for each row in the table, then it is entirely reasonable that every row gets updated because every row qualifies for the update. That's why I suggested you provide sample data, expected results and actual results: if you had done that, I probably wouldn't have to ask this followup question.

What language is your code? It looks a bit like Perl to me but I sometimes confuse Perl and PHP.

Is '!=' a legitimate way to say 'not equal' in this version of MySQL and the language you are using? I normally use either the NOT keyword or the symbols '<>' to negate conditions, for example:
- WHERE NOT subscribe = ''
- WHERE subscribe <> ''
Some dialects of SQL and some programming languages support '!=' but not all of them do. You should check that in the MySQL reference for 3.23 and the programming language, whatever it is.

Are you sure you are executing the statement against the table you _think_ you are updating? For example, Is it possible that you mean to execute the statement against a production table but are actually executing it against a test table that has very different data than the production table?

--
Rhino

----- Original Message ----- From: "Bruce Therrien" <[EMAIL PROTECTED]>
To: "Rhino" <[EMAIL PROTECTED]>
Sent: Saturday, February 25, 2006 4:37 PM
Subject: Re[2]: using WHERE and OR in a query


the query is updating all records with no regards to the WHERE clauses.


On Sat, 25 Feb 2006 16:36:38 -0500
"Rhino" <[EMAIL PROTECTED]> wrote:

Define "not work": do you mean you get a compile error? A runtime error? Or
a result that differs from what you expected?

If you got an error message, please state the full message text. If the
result simply differed from what you wanted, please give us a small sample
of data, your expectations for what the result should have been, and
information about what you actually got.

The CREATE TABLE statement could also be helpful in determining what went
wrong.

--
Rhino

----- Original Message ----- From: "Bruce Therrien" <[EMAIL PROTECTED]>
To: <mysql@lists.mysql.com>
Sent: Saturday, February 25, 2006 4:28 PM
Subject: using WHERE and OR in a query


> Why does this query not work using mysql 3.23.58?
>
> $SQL =<<SQL;
> UPDATE $tablename SET rank = '$qdj_rank_en', rank_icon = > '$qdj_rank_icon',
> qdj = qdj+'$adata{qdj_credit}', gold = gold+'$adata{gold_credit}' WHERE
> subscribe != '' OR artist = '1' OR rank_change != '1'
> SQL
> $dbh->do($SQL) ||  &cgierr("Reason: $!");
>
>
>
> -- > Bruce Therrien <[EMAIL PROTECTED]>
>
> This is the end of the internet.
> Please turn around and go back.
>
>
> -- > MySQL General Mailing List
> For list archives: http://lists.mysql.com/mysql
> To unsubscribe: > http://lists.mysql.com/[EMAIL PROTECTED]
>
>
> -- > No virus found in this incoming message.
> Checked by AVG Free Edition.
> Version: 7.1.375 / Virus Database: 268.1.0/269 - Release Date: > 24/02/2006
>
>



--
No virus found in this outgoing message.
Checked by AVG Free Edition.
Version: 7.1.375 / Virus Database: 268.1.0/269 - Release Date: 24/02/2006


--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe: http://lists.mysql.com/[EMAIL PROTECTED]



--
Bruce Therrien <[EMAIL PROTECTED]>

This is the end of the internet.
Please turn around and go back.


--
No virus found in this incoming message.
Checked by AVG Free Edition.
Version: 7.1.375 / Virus Database: 268.1.0/269 - Release Date: 24/02/2006





--
No virus found in this outgoing message.
Checked by AVG Free Edition.
Version: 7.1.375 / Virus Database: 268.1.0/269 - Release Date: 24/02/2006


--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:    http://lists.mysql.com/[EMAIL PROTECTED]

Reply via email to