I'm having a bit of trouble getting my syntax right for this SQL statement.
I want the query to read through all the cat values in the table, and enter
the value "1" in an empty column wherever the cat value is divisible by 60
with no remainder (cat % 60 == 0). Here's what I enetered:
echo 'UPDATE Opil184a_ship_nav_med_smth SET MOD_60==1 WHERE (cat%60)==0' |
db.execute
I know there has to be something wrong with that WHERE clause, but my SQL's
really bad.
Any ideas?
~ Eric.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Eric Patton
Technologist, Geo-Spatial Data Services
Geological Survey of Canada (Atlantic)
Natural Resources Canada
Bedford Institute of Oceanography
Dartmouth, Nova Scotia, Canada B2Y 4A2
Postal address: P.O. Box 1006
Courier address: 1 Challenger Drive
Telephone: (902)426-7732
Facsimile: (902)426-4104
E-mail: <mailto:epatton@NRCan.gc.ca> epatton@NRCan.gc.ca
Patton, Eric wrote:
I'm having a bit of trouble getting my syntax right for this SQL statement.
I want the query to read through all the cat values in the table, and enter
the value "1" in an empty column wherever the cat value is divisible by 60
with no remainder (cat % 60 == 0). Here's what I enetered:
echo 'UPDATE Opil184a_ship_nav_med_smth SET MOD_60==1 WHERE (cat%60)==0' | db.execute
^^
You're using '==' for an assignment, when it should be '='.
--
Glynn Clements <glynn@gclements.plus.com>
On Mon, 19 Sep 2005 12:12:36 -0300
"Patton, Eric" <epatton@nrcan.gc.ca> wrote:
I'm having a bit of trouble getting my syntax right for this SQL statement.
I want the query to read through all the cat values in the table, and enter
the value "1" in an empty column wherever the cat value is divisible by 60
with no remainder (cat % 60 == 0). Here's what I enetered:
echo 'UPDATE Opil184a_ship_nav_med_smth SET MOD_60==1 WHERE (cat%60)==0' |
db.execute
I know there has to be something wrong with that WHERE clause, but my SQL's
really bad.
Any ideas?
~ Eric.
Eric,
I noticed two things. First the use of double equal signs, use single equal signs. Second, you realize that if you cats with a value of zero, the will also be updated so you should use something like:
echo 'UPDATE Opil184a_ship_nav_med_smth SET MOD_60 = 1 WHERE (cat%60) = 0 and cat <> 0' | db.execute
T
--
Trevor Wiens
twiens@interbaun.com
The greatest obstacle to discovery is not ignorance - it is the illusion of knowledge.
(Daniel J. Boorstin)