Granpoh wrote:How do you change the order of fields within a table?
Incorrect.Granpoh wrote:All that seems to do is permit me to take a field and choose if I want the data received into that field to be in either ascending or descending order.
Sharley wrote:3. You need to locate the column type of the field name you wish to move from the list in the structure window, for example it might be field one varchar(255) and I will use that example in the SQL query below.
Type in the box: ALTER TABLE blah1 MODIFY COLUMN one varchar(255) AFTER three [/b]
4. Click on Go
The full syntax is and just add your own specific names like in the example above.
ALTER TABLE table MODIFY COLUMN columnnamebefore colnamebeforecoltype AFTER columnnametomoveafter
Sharley wrote:You will get an error message if it is not working - paste the error messages here.
Also paste here exactly what you are typing in the SQL query text box.
ALTER TABLE blah1 MODIFY COLUMN one varchar(255) AFTER three [/b]
Sorry for my typo that should be minus the [/b]
ALTER TABLE blah1 MODIFY COLUMN one varchar(255) AFTER three
You will need to change the bold names to suit your own database names.
ALTER TABLE = is blah1 table
MODFIFY COLUMN = is field one
Column Type = is varchar(255)
Put field one AFTER field three
I will edit my other post to get rid of the errant forum tag.
Spaces are not allowed in names.
ALTER TABLE `users` MODIFY COLUMN `Last Name` varchar(20) AFTER `First Name`;
Wiedmann wrote:Spaces are not allowed in names.
That's not correct.
-->
- Code: Select all
ALTER TABLE `users` MODIFY COLUMN `Last Name` varchar(20) AFTER `First Name`;
( But it's easier to work without them. It's also better to work only with lower case letters.)
Dave_L wrote:If you use spaces in identifier names, they have to be quoted as above, so they won't be interpreted as field separators. It's simpler if you don't use spaces.
Mixing uppercase and lowercase characters leads to problems and confusion when you're in a case-sensitive environment. If you always use all lowercase, you never have to worry about that.
The backticks (`), not single quotes ('), around the identifier names are needed only if an identifier contains spaces or other characters used by MySQL, or if the identifier is a MySQL reserved word. But it's a good idea to use the backticks all the time, to avoid possible problems. This applies to database names, table names, column names, index names and aliases.
Users browsing this forum: No registered users and 61 guests