3

Here is my table funcionario:

ID_funcionario  nome    numero  sexo    morada    email     data_nasc
-----------------------------------------------------------------------
1              marcio   1234    male    jardim    marcio    11/23/2017
2              joel     3333    male   bemfica     ragy     11/25/2017 

I want to select specifically only the nome "marcio" and number 1234.

For example, it should appear like this:

nome    numero  
----------------
marcio  1234

This is what I tried:

select * 
from funcionario 
where nome = 'marcio' and numero = '1234';

but that just shows me the whole row like this:

ID_funcionario  nome    numero  sexo    morada    email     data_nasc
----------------------------------------------------------------------
1              marcio   1234    male    jardim    marcio    11/23/2017

4 Answers 4

3

When you use select * ..., all the columns of the table are returned.

If you want to get only some columns, then you must be more specific, like this:

select nome, numero 
from funcionario 
where nome = 'marcio' and numero = '1234';
Sign up to request clarification or add additional context in comments.

1 Comment

You are welcome! If it helped, please select this as an answer (the checkmark bellow the answer) :)
2

You are selecting every column by this: SELECT * FROM ...

try to select the columns you need by:

select nome, numero from funcionario where nome ='marcio'and numero='1234';

Comments

2

In addition to the answers above, you could also write it this way:

select nome, numero 
from funcionario 
where nome = 'marcio' 

It will return your desired result as well.

Comments

0

SELECT * FROM [TABLENAME] WHERE Col1 = ''

or

SELECT T_Col1, T_Col2 FROM [TABLENAME] WHERE T_Col1 = ''

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.