Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Sqlite: SELECT * BUT id FROM Table

Tags:

sql

select

sqlite

I have many columns in a table and wanted to SELECT * FROM Table except for one column (ex: location) without having to list all the columns I want to use.

SELECT * EXCEPT id FROM Table???

like image 898
Brandon Nadeau Avatar asked Mar 24 '13 11:03

Brandon Nadeau


People also ask

How do I SELECT specific data in SQLite?

To select data from an SQLite database, use the SELECT statement. When you use this statement, you specify which table/s to select data from, as well as the columns to return from the query. You can also provide extra criteria to further narrow down the data that is returned.

How do I SELECT a specific column in SQLite?

SQLite select specific columns We can use the SELECT statement to retrieve specific columns. The column names follow the SELECT word. We retrieve the Name and the Price columns. The column names are separated by commas.

Does except work in SQLite?

The EXCEPT operator returns all records from the first SELECT statement that are not in the second SELECT statement. The EXCEPT operator in SQLite is equivalent to the MINUS operator in Oracle.


2 Answers

Absolutely, no.

But here's a workaround. Create a VIEW of the table, eg

CREATE VIEW ViewName
AS
    SELECT col1, col2, col3, .... -- don't select the column name you want to hide
    FROM tableName;

once the VIEW was created, you can now call it,

SELECT * FROM ViewName
like image 79
John Woo Avatar answered Nov 11 '22 15:11

John Woo


No, you cannot do that.

You list the ones you need, or you accept that the result set contains one more column than you need.

like image 43
Lasse V. Karlsen Avatar answered Nov 11 '22 15:11

Lasse V. Karlsen