How to select multiple columns from a table excluding some columns?
I tried:
SELECT *!=[column name i want to exclude] from tablename;
it didn't work.
Also, as mentioned in Joe's comment, it is usually considered good practice to explicitly specify column list as opposed to "*" even when selecting all columns. The reason for that is that having * in a joined query may cause the query to break if a table schema change introduces identically-named fields in both of the joined tables.
Example 1: Select first two column. # slice inclusive of the ending index. Example 2: Select all or some columns, one to another using .iloc. Select all or some columns, one to another using .ix.
Selecting multiple columns in SQL with or without any condition is as simple as selecting a single column and not only simple but also the same as that.
Similarly, another example of multiple columns can be: Write a query which gave the names and salary of all employees working in an organization. So here we have to select 2 columns of name and salary. The examples above make us understand that selection of columns is very important while learning SQL.
select column1, column2, column4, column7
from tablename;
should be the way to go.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With