Solved

PHP/Mysql: Drop Column

Posted on 2007-11-30
2
838 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
2 Comments
 
LVL 17

Accepted Solution

by:
nplib earned 250 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 50

Assisted Solution

by:Steve Bink
Steve Bink earned 250 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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

Password hashing is better than message digests or encryption, and you should be using it instead of message digests or encryption.  Find out why and how in this article, which supplements the original article on PHP Client Registration, Login, Logo…
Introduction This article is intended for those who are new to PHP error handling (https://www.experts-exchange.com/articles/11769/And-by-the-way-I-am-New-to-PHP.html).  It addresses one of the most common problems that plague beginning PHP develop…
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

820 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