0

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

closed as off-topic by Paul White, Vérace, Michael Green, RLF, RolandoMySQLDBA Apr 24 '15 at 16:09

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "Too localized - this could be because your code has a typo, basic error, or is not relevant to most of our audience. Consider revising your question so that it appeals to a broader audience. As it stands, the question is unlikely to help other users (regarding typo questions, see this meta question for background)." – Paul White, Vérace, Michael Green, RLF, RolandoMySQLDBA
If this question can be reworded to fit the rules in the help center, please edit the question.

  • 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
0

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.

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