mysql4

Summing a comma separated column in MySQL 4 (not 5)

时光怂恿深爱的人放手 提交于 2019-12-17 10:02:05
问题 I'm writing a query that selects data from one table into another, one of the columns that needs to be moved is a DECIMAL column. For reasons beyond my control, the source column can sometimes be a comma separated list of numbers. Is there an elegant sql only way to do this? For example: source column 10.2 5,2.1 4 Should produce a destination column 10.2 7.1 4 I'm using MySQL 4, btw. 回答1: To do this kind of non trivial string manipulations, you need to use stored procedures, which, for MySQL,

Drop constraints only if it exists in mysql server 5.0

允我心安 提交于 2019-12-10 17:00:24
问题 i want to know how to drop a constraint only if it exists. is there any single line statement present in mysql server which will allow me to do this. i have tried the following command but unable to get the desire output alter table airlines drop foreign key if exits FK_airlines; any help to this really help me to go forward in mysql 回答1: I do not believe this is possible in a single line, unless you are willing to detect the error and move on (not a bad thing). The INFORMATION_SCHEMA

Using ALTER to drop a column if it exists in MySQL

假如想象 提交于 2019-11-27 01:05:28
How can ALTER be used to drop a column in a MySQL table if that column exists? I know I can use ALTER TABLE my_table DROP COLUMN my_column , but that will throw an error if my_column does not exist. Is there alternative syntax for dropping the column conditionally? I'm using MySQL version 4.0.18. For MySQL, there is none: MySQL Feature Request . Allowing this is arguably a really bad idea, anyway: IF EXISTS indicates that you're running destructive operations on a database with (to you) unknown structure. There may be situations where this is acceptable for quick-and-dirty local work, but if

Using ALTER to drop a column if it exists in MySQL

折月煮酒 提交于 2019-11-26 09:32:37
问题 How can ALTER be used to drop a column in a MySQL table if that column exists? I know I can use ALTER TABLE my_table DROP COLUMN my_column , but that will throw an error if my_column does not exist. Is there alternative syntax for dropping the column conditionally? I\'m using MySQL version 4.0.18. 回答1: For MySQL, there is none: MySQL Feature Request. Allowing this is arguably a really bad idea, anyway: IF EXISTS indicates that you're running destructive operations on a database with (to you)