NOTE: use Perl; is on undef hiatus. You can read content, but you can't post it. More info will be forthcoming forthcomingly.
All the Perl that's Practical to Extract and Report
Stories, comments, journals, and other submissions on use Perl; are Copyright 1998-2006, their respective owners.
Re: Spot the SQL bug (Score:2)
Just making it a bit clearer than the first reply. (Score:1)
ANDwith a comma and everything should be okay. Like so:Did just stumble about this around a week ago
Re:Just making it a bit clearer than the first rep (Score:2)
Re:Just making it a bit clearer than the first rep (Score:1)
You might want to do something with TO_LOWER() (in case of Oracle) in the WHERE clause. This will cause any indexes on the STATE and CITY column to be ignored (unless you used function-based indexes ).
UPDATE users
SET state = 'DC', city = 'Washington'
WHERE TO_LOWER(state) = 'dc'
AND TO_LOWER(city) = 'washington'
mark
Re:Just making it a bit clearer than the first rep (Score:2)
Re:Just making it a bit clearer than the first rep (Score:1)
I'm not sure if I like the idea of case-insensitive columns (especially for names). But that's my personal opinion and it's configurable so I can always turn case-sensitivity on
mark
That reminds me... (Score:1)
Re:That reminds me... (Score:1)
Re:That reminds me... (Score:1)
This works if your RDBMS supports UNION queries. AFAIK MySQL does this since 4.0.0.
In this example I would not use this method. The
city = 'New York' or city = 'Los Angeles'is much better.mark
Re:That reminds me... (Score:1)