0

I have created an sql table in phpmyadmin which gets its information from an form on a website. I have one column that populates with the street address information but it is too narrow and the street address wraps to the next line instead of being on one line. I have tried the following:

ALTER TABLE `b` 
ALTER COLUMN `c` varchar(200) 

as some have suggested in other answers here but I get an error

#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 'char(200)' at line 1

I am very new to sql so I do not have much of an arsenal of knowledge to fall back on, whats online is limited and did not work for me. Can someone please provide an answer as to how I can increase the width of a column to accommodate the varying sizes of the addresses collected.

[screenshot of table

Jay Blanchard
  • 34,243
  • 16
  • 77
  • 119
falcon
  • 13
  • 2
  • Are you certain that is *exactly* what you entered? – Siyual Jan 09 '17 at 21:33
  • Possible duplicate of [How to change MySQL column definition?](http://stackoverflow.com/questions/1595372/how-to-change-mysql-column-definition) – Funk Forty Niner Jan 09 '17 at 21:38
  • If an answer solved your problem, consider accepting the answer. Here's how http://meta.stackexchange.com/questions/5234/how-does-accepting-an-answer-work then return here and do the same with the tick/checkmark till it turns green. This informs the community, a solution was found. Otherwise, others may think the question is still open and may want to post (more) answers. You'll earn points and others will be encouraged to help you. *Welcome to Stack!* – Jay Blanchard Jan 09 '17 at 21:41

1 Answers1

2

The syntax you need for MySQL -

ALTER TABLE `b` MODIFY COLUMN `c` VARCHAR(200);
Jay Blanchard
  • 34,243
  • 16
  • 77
  • 119
  • thank you, the query finally gets accepted. when I ran the app and checked the text still wraps. I am inputting the query in in the query box under the sql tab. Am i putting it in the right place? – falcon Jan 09 '17 at 21:45
  • Run `DESCRIBE b;` to check your table configuration. – Jay Blanchard Jan 09 '17 at 21:47
  • this is the result --- b varchar(200) YES MUL NULL – falcon Jan 09 '17 at 21:49
  • You may want to make the column type `TEXT` – Jay Blanchard Jan 09 '17 at 21:51
  • If it is wrapping it isn't because of your table, it is because of the container you're displaying the text in or you have hidden line breaks/carriage returns. – Jay Blanchard Jan 09 '17 at 21:54
  • not sure if that is the case, it cuts off even in the middle of the word when it reached the width limit and wraps to next line in the column. – falcon Jan 09 '17 at 22:00
  • Where are you viewing this? – Jay Blanchard Jan 09 '17 at 22:02
  • under the browse section of phpmyadmin. it also shows the same way when viewed in print view and print view full text – falcon Jan 09 '17 at 22:04
  • 1
    You have successfully modified the underlying table, but the web page you're viewing it in is where the problem is. If you stretched the view across a couple of monitors and then widened the column you're looking at, there would be no wrap. – Jay Blanchard Jan 09 '17 at 22:06
  • phpMyAdmin is just a tool - it is an interface for your MySQL database. The designer placed rules on how the interface looks (using CSS), including how each column is displayed. If you were to create a web page which would connect to the database and display the column you would have control over the width and how the data is displayed. – Jay Blanchard Jan 09 '17 at 22:10
  • thank you, I appreciate the time to clarify. I do realize I have a ways to go as this is my first time working directly with databases. I did add a screenshot, something i probably should have done earlier. Thanks again, I gained good knowledge from this exchange. – falcon Jan 09 '17 at 22:25
  • If you have worked with spreadsheets you know how to click between column headers and stretch a colum. It works the same way in phpMyAdmin. Use your mouse to click between 'address' and 'zip', the drag the column width. – Jay Blanchard Jan 09 '17 at 22:26
  • I actually had tried the excel method to stretch the width out but that option is not available but it seems like it might be something on my end that is not allowing it. – falcon Jan 09 '17 at 22:30