Web Hosting Talk







View Full Version : Simple MySQL error question


simcoweb
09-13-2005, 02:20 PM
I'm a newb with the MySQL syntax but i'm going through the manual trying to deal with updating a column in a MySQL table.

Table name is: affacct
Field/column name: affacct_active

I've tried this syntax:

UPDATE affacct
SET affacct_active=Y

Thinking that this is going to update the affacct_active by replacing the current entry (which is an 'A' ) into a 'Y'. Instead, I get this error:

#1054 - Unknown column 'Y' in 'field list'

I've looked at the UPDATE syntax in the MySQL documentation and can't figure what i'm doing wrong here but it's looking for the field name 'Y' instead of the field name i've designated.

A little help please?

mconnors
09-13-2005, 02:36 PM
try adding Y in single quotes....

UPDATE affacct
SET affacct_active='Y'

simcoweb
09-13-2005, 02:50 PM
Pure genius.

Amazing how every example I looked at including the MySQL official documentation didn't have single quotes.

Worked like a charm. Thanks!

hiryuu
09-13-2005, 04:31 PM
You can use double quotes ("), too. The examples were probably numbers, which don't need to be quoted, because they can't be confused with column names.

someotherguy
09-13-2005, 06:31 PM
But remember if you are enclosing the query with double quotes ("), then you must put a backslash in front out any "s where you dont want the query to end. Same goes with single quotes (').

simcoweb
09-13-2005, 07:11 PM
Wow! Didn't expect this much help! :)

Ok, well, perhaps another question. I'm getting a database error at this URL:

http://www.forfreelance.com

No idea what could be causing this. The software was jut reinstalled due to a crash on the server. Some sort of syntax issue.

someotherguy
09-13-2005, 10:31 PM
Whoa. I I've never seen queries like that before. Im not all that great on queries, but I this something is really messed up, and it looks like some of the < and > have nothing to refer to.

Did you upgrade / downgrade your MySQL version?

Burhan
09-14-2005, 02:42 AM
The queries are not complete, seems like your application is not configured properly.

For example :

SELECT *,CASE WHEN maxbudget> AND >0 THEN 5 WHEN minbudget> AND >0

There needs to be a number there, for example :

SELECT *, CASE WHEN maxbudget > 100 AND minbudget > 0 THEN 5 WHEN minbudget > [somenumber] AND [somecolumn] > 0

I suggest to contact the developers or read the documentation.