I have a very strange scenario and would be highly grateful if you can help me out. I have one flat table of five fields, and I need to select everything from say the last three columns.
我有一个非常奇怪的场景,如果你能帮助我,我将非常感激。我有一个包含五个字段的平面表,我需要从最后三列中选择所有内容。
SAMPLE:
ID CODE BRAND T1 T2
== ==== ===== == ==
1 KUU RR4 1 2
2 KUU R56 2 1
=====================
I need only the values of T1 and T2. The reason I need to get the last two columns is that the table is generated automatically from an Excel file, so the first three columns are static (ID, CODE, BRAND), and only last two columns are dynamic (T1, T2) and can be different next time, like (P1, P2), so I cannot do something like SELECT T1, T2 FROM sampleTable. I am totally stumped any help or advice would be great.
我只需要T1和T2的值。我需要获取最后两列的原因是该表是从Excel文件自动生成的,因此前三列是静态的(ID,CODE,BRAND),并且最后两列是动态的(T1,T2)和下次可能会有所不同,比如(P1,P2),所以我不能做像SELECT T1,T2 FROM sampleTable这样的事情。我完全难过任何帮助或建议会很棒。
2 个解决方案
#1
1
You didn't mention php, but there it is in the tags so:
你没有提到php,但它在标签中是这样的:
In your php script, you could select the whole shebang and still access the fields in a numeric order. For example:
在您的PHP脚本中,您可以选择整个shebang并仍然以数字顺序访问字段。例如:
$q=mysqli_query("SELECT * FROM SAMPLE");
while($row=mysqli_fetch_array($q,MYSQLI_NUM))
{
printf("col#4: %s -- col#5: %s",$row[3],$row[4]);
}
#2
0
SELECT 4,5 FROM SampleTable;
SELECT 4,5 FROM SampleTable;
4,5 specifies the column number in your table.
4,5指定表中的列号。
#1
1
You didn't mention php, but there it is in the tags so:
你没有提到php,但它在标签中是这样的:
In your php script, you could select the whole shebang and still access the fields in a numeric order. For example:
在您的PHP脚本中,您可以选择整个shebang并仍然以数字顺序访问字段。例如:
$q=mysqli_query("SELECT * FROM SAMPLE");
while($row=mysqli_fetch_array($q,MYSQLI_NUM))
{
printf("col#4: %s -- col#5: %s",$row[3],$row[4]);
}
#2
0
SELECT 4,5 FROM SampleTable;
SELECT 4,5 FROM SampleTable;
4,5 specifies the column number in your table.
4,5指定表中的列号。