0

I got a table (called users) with n column ( n= one billion columns) like this:

id, email,username,...,...,...,..col_n.

I want to show all data exclusion id, email with the only Select query. i don't want to type all field what i want.

How can i do that?

For example: Table users:

+--------+----------+------------+-----------+
| userid | username | password   | privilege |
+--------+----------+------------+-----------+
|      1 | user1    | password   |         1 |
|      2 | david    | goodboy    |         1 |
|      3 | admin    | mastermold |         5 |
|      4 | user4    | password4  |         1 |
|      5 | user5    | password5  |         2 |
|      6 | user6    | password6  |         1 |
|      7 | user7    | password7  |         1 |
+--------+----------+------------+-----------+

The result after run query like this:

+--------+----------+
| userid | username |
+--------+----------+
|      1 | user1    |
|      2 | david    |
|      3 | admin    |
|      4 | user4    |
|      5 | user5    |
|      6 | user6    |
|      7 | user7    |
+--------+----------+

My problem: my table have one billion fields and i have to use the only one select query.

M Khalid Junaid
  • 63,861
  • 10
  • 90
  • 118
jackvn
  • 11
  • 3
  • possible duplicate of [SQL exclude a column using SELECT \* \[except columnA\] FROM tableA?](http://stackoverflow.com/questions/729197/sql-exclude-a-column-using-select-except-columna-from-tablea) – Linga Jan 02 '14 at 06:34
  • Also possible duplicate of: [How can I “select *” from a table in MySQL but omit certain columns?](http://stackoverflow.com/questions/2365972/how-can-i-select-from-a-table-in-mysql-but-omit-certain-columns/13808457#13808457) – Jacob Budin Jan 02 '14 at 06:42
  • @ Jacob Budin. yes, that is my mean – jackvn Jan 02 '14 at 06:47
  • My problem: Only using one query – jackvn Jan 02 '14 at 06:57

1 Answers1

0

One solution is the following. This may not be much efficient but you can try this.

Create a TEMPORARY TABLE and drop id and email from it and use it for query.

CREATE TEMPORARY TABLE temp_users SELECT * FROM users;
ALTER TABLE temp_users DROP id,email;
SELECT * FROM temp_users;
Sabin Jose
  • 658
  • 9
  • 19