[英]SELECT statement to show extra columns
Table1 表格1
Code | 代码 Type |
类型 Color |
颜色| Description |
描述
1 | 1 | Fruit |
水果 Red |
红色| apple
苹果
1 | 1 | Fruit |
水果 Orange |
橙色| peach
桃子
1 | 1 | Fruit |
水果 Blue |
蓝色| blueberry
蓝莓
1 | 1 | Fruit |
水果 Green |
绿色| sour apple
酸苹果
1 | 1 | Fruit |
水果 Yellow |
黄色| lemon
柠檬
I'm running the code below: 我正在运行以下代码:
SELECT
code,
type,
color,
description
FROM table
If someone sends me a CSV with additional columns is there a code that I can add that produces the string Error in the additional columns fields? 如果有人向我发送包含其他列的CSV,是否有我可以添加的代码在其他列字段中产生字符串Error ?
I won't know the additional columns name since it's up to the user to designate it--All I want to produce is the effect that if they did I'll know if there was an additional field added. 我不知道其他列的名称,因为要由用户指定它-我要产生的效果是,如果不指定,我将知道是否添加了其他字段。
The MySQL LOAD DATA command MySQL LOAD DATA命令
In other words, you'll always load Code , Type , Color and Description into your table, regardless of input malformations. 换句话说,无论输入格式如何,都将始终将Code , Type , Color和Description加载到表中。
There is a possible workaround to find lines with one or more extra columns: load the file into an empty auxiliary table with 5 columns with a NULL default. 有一种可能的解决方法来查找具有一或多个额外列的行:将文件加载到具有5列且默认值为NULL的空辅助表中。 If any line in the CSV file has 5 or more columns, the test table will contain records in which the fifth column
IS NOT NULL
; 如果CSV文件中的任何一行有5列或更多列,则测试表将包含第五
IS NOT NULL
; you can count them. 你可以数一下
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.