Solved

PHP/Mysql: Drop Column

Posted on 2007-11-30
2
832 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

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

Popularity Can Be Measured Sometimes we deal with questions of popularity, and we need a way to collect opinions from our clients.  This article shows a simple teaching example of how we might elect a favorite color by letting our clients vote for …
This article discusses how to create an extensible mechanism for linked drop downs.
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
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 …

759 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

Need Help in Real-Time?

Connect with top rated Experts

26 Experts available now in Live!

Get 1:1 Help Now