Take the 2-minute tour ×
Database Administrators Stack Exchange is a question and answer site for database professionals who wish to improve their database skills and learn from others in the community. It's 100% free, no registration required.

i am new to database querying so apologies for this rudimentary query question. thank you in advance.

table called "neuron"  
columns in "neuron" called "neuron_id", "neuron_name" + others (not relevant here)

neuron_id is unique identifier for each neuron_name;
say there are 5 entries, thus
neuron_id = 1,2,3,4,5 and corresponding
neuron_name = a,b,c,d,e

i would like to generate a list that contains neuron_id for select neuron_name. the following query does not work for me.

select neuron_id, neuron_name  
from neuron  
where neuron_name = "a" or "c" or "e"

i expect the following

1,a  
3,c  
5,e

but the above query only spits out

1,a
share|improve this question
    
WHERE neuron_name IN ('a', 'c', 'e') –  ypercube Feb 12 at 15:03
    
thank you Max for the format edits. –  rsp Feb 13 at 16:52
add comment

2 Answers 2

Try this:

select neuron_id, neuron_name  
from neuron  
where neuron_name = "a" or neuron_name = "c" or neuron_name = "e"

Edit:

The solution from ypercube is more semantically correct.

select neuron_id, neuron_name  
from neuron  
where neuron_name IN ('a', 'c', 'e')
share|improve this answer
    
thank you. this worked! –  rsp Feb 13 at 16:54
add comment

Copy and modify this.

select * from seq_region where (name = 'MtDNA' or name = 'IV');

We're both biologists! HTH, Paul...
(first solution possibly more elegant, but with OR you can add other fields - YMMV)

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.