Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

PHP/Mysql: Drop Column

Posted on 2007-11-30
2
Medium Priority
?
850 Views
Last Modified: 2013-12-12
I am doing this:

mysql_query("ALTER TABLE model DROP COLUMN Column1");

but it says:

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 'column='Column1'' at line 1

But if i check the table, the column does get removed though...

0
Comment
Question by:jtcy
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 17

Accepted Solution

by:
nplib earned 1000 total points
ID: 20383001
You've got an error in another sql statement, probably one that runs after that column gets removed and tries to reference the removed column.
0
 
LVL 51

Assisted Solution

by:Steve Bink
Steve Bink earned 1000 total points
ID: 20385671
I'm with nplib.  You'll have to narrow down when the error is coming back, and which query is causing it.  The manual has this to say about altering tables:

>>> In most cases, ALTER TABLE works by making a temporary copy of the original
>>> table. The alteration is performed on the copy, and then the original table is
>>> deleted and the new one is renamed. While ALTER TABLE  is executing, the
>>> original table is readable by other clients. Updates and writes to the table are
>>> stalled until the new table is ready, and then are automatically redirected to
>>> the new table without any failed updates.

If you have other updates or writes going on in the background (for example, on another httpd thread using the same database), those queries will be delayed until the ALTER TABLE is finished.  When they do run, they will on the new version of the table.
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Many old projects have bad code, but the budget doesn't exist to rewrite the codebase. You can update this code to be safer by introducing contemporary input validation, sanitation, and safer database queries.
Originally, this post was published on Monitis Blog, you can check it here . In business circles, we sometimes hear that today is the “age of the customer.” And so it is. Thanks to the enormous advances over the past few years in consumer techno…
The viewer will learn how to dynamically set the form action using jQuery.
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.
Suggested Courses

618 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question