How to select a column to compare two values in it with AND

select distinct c.reg#, a.fname, a.lname, to_char(b.L#) as "L"
  from employee a, driver b, trip c
  where a.e#=b.e#
  and b.l#=c.l#
  and (c.reg#='PKR3344'AND c.reg#='WWF1155')
order by c.reg#;

error no rows selected I want c.reg# for the two values inclusive

  • How could reg be at the same time equal to two different things? You need or, not and. – Mat Apr 24 '15 at 5:07
  • Give us some sample DDL (CREATE TABLE employee (id int...)) and some sample DML (INSERT INTO employee VALUES(...)) and the result you want from that data and we'll see what we can do. For the moment, I'm voting to close the question as too vague. Check the "help us to help you" blog on the bottom left of the page. – Vérace Apr 24 '15 at 5:32
  • How would I implement XOR for the two values? – DBAStudent Apr 24 '15 at 7:07

If I understand right you need select records that equals two values. You can look this query like exsample:

SELECT firm_property.firm_id, firm.title
FROM  firm_property INNER JOIN
   firm ON firm_property.firm_id = firm.id
WHERE  (firm_property.property_id IN ('PKR3344', 'WWF1155'))
GROUP BY firm_property.firm_id, firm.title
HAVING  (COUNT(*) = 2)

If you write your tables and treir data we can make the better answer query.

| improve this answer | |

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