Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6815925
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T20:51:53+00:00 2026-05-26T20:51:53+00:00

I have a SQL table with three columns (key, id, loglevel). The key column

  • 0

I have a SQL table with three columns (key, id, loglevel). The key column is set as the primary key, and is auto-incremented.

Imagine this:

key   id   loglevel
1     223     5
2     445     8

Now I want to update the table by selecting the row thata corresponds to a specific value of “key”.

I am using the line:

mysql_query("UPDATE Logs SET loglevel = 4 WHERE key = 2;"); 

However this doesn’t work.

When I change it to

mysql_query("UPDATE Logs SET loglevel = 4 WHERE id = 445;");

it works fine. However, I want to update based on “key” and not “id”.

Any ideas what I’m doing wrong?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T20:51:54+00:00Added an answer on May 26, 2026 at 8:51 pm

    In MySQL key is a reserved word and must be quoted.

    "UPDATE Logs SET loglevel = 4 WHERE `key` = 2"
    

    I’d also strongly recommend that you look at the value of mysql_error when your query fails as this may have given you the hint you needed to solve this yourself.

    Error Code: 1064. You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ‘key’ at line 1

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm using SQL Server 2008 and I have a table with three columns: Length
Given a table that has three columns ID (Primary Key, not-autoincrementing) GroupID SomeValue I
In a SQL Server table I have the following 2 columns: RowId : primary
I have a table in SQL Server 2005 whose primary key is an identity
Hi there I have an SQL table that looks like this: CREATE TABLE IF
This is a SQL design question. First, the setup. I have three tables: A,
I have a table (SQL Server 2005) with the following columns: State: - StateId
I have a table named employee_salary , with three columns: empsal_id , empsal_name and
We have a few tables with persisted computed columns in SQL Server. Is there
I have a Microsoft SQL Server 2008 query that returns data from three tables

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.