1
SELECT *
FROM customers
WHERE customer_name NOT IN ( 'IBM', 'Hewlett Packard', 'Microsoft' );

I want to write a query in my task which is similar to the above query,and my task is in ruby on rails.

1

1 Answer 1

3

If you are using Rails 4, the following will do

Customer.where.not(customer_name: ['IBM', 'Hewlett Packard', 'Microsoft'])

For Rails versions lower than Rails 4, the below will work

Customer.where("customer_name NOT IN (?)", ['IBM', 'Hewlett Packard', 'Microsoft'])
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.