I'm using the MySql C API and doing various queries I found it very inconvenient to go check the query each time to see the column ordering. Moreover, this approach is very prone to errors in case of a query edit.

**Is there anything I can do to assign by query each column ordinal?**

If not, is there a more convenient way to retrieve results via the C API? (currently using `mysql_fetch_row` and accessing the column id with the subscript operator).

Please not that I read the similar question [Is it possible to sort the order in which columns are returned in a mysql SELECT statement?](https://stackoverflow.com/questions/34583349/is-it-possible-to-sort-the-order-in-which-columns-are-returned-in-a-mysql-select), but I found it different from my case as I need to assign an arbitrary number of column ordinals.

**Edit:**

**Current situation**

query: `SELECT A.a, A.b, A.c FROM tbl1 A INNER JOIN tbl2 B ON B.id = A.B_id`

c code: 

```
...
MYSQL_ROW row = mysql_fetch_row(result);
unsigned long *lengths = mysql_fetch_lengths(result);
...
int field1 = atoi(row[0]);
memcpy(row[1], field2, lengths[1]); 
..continue for each row..

```

**Desired situation**

query: `SELECT A.a ORDINAL 1, A.b ORDINAL 2, A.c ORDINAL 3 FROM tbl1 A INNER JOIN tbl2 B ON B.id = A.B_id`

c code: same as above.

Where `ORDINAL` statements are pseudo-SQL statements that would allow the returned columns to be ordered at wish.