Question: I want to produce the following sql using active record.

```
WHERE (column_name1, column_name1) IN (SELECT ....)

```

I don't know how to do this is active record.

I've tried these so far

```
where('column_name1, column_name2' => {})
where([:column_name1, :column_name2] => {})

```

This is the full query I'd like to create

```
SELECT a, Count(1) 
            FROM   table 
            WHERE  ( a, b ) IN (SELECT a, 
                                    Max(b) 
                                    FROM   table 
                                    GROUP  BY a) 
            GROUP  BY a 
            HAVING Count(1) > 1)

```

I've already written a scope for the subquery

Thanks in advance.

Answer: 
You set validInput to false, when it fails, but you never set validInput to true, when the input is, in fact, valid.

Just add an else block to your if block, setting validInput to true.
It's because if the input is wrong, it's not extracted and removed from the input buffer, and since you call [`std::istream::ignore`](http://en.cppreference.com/w/cpp/io/basic_istream/ignore) without argument you only extract a single character from the invalid input, and if there's more invalid input after that then your next input will read that.

You could use [`std::istream::ignore`](http://en.cppreference.com/w/cpp/io/basic_istream/ignore) to extract (and discard) input until the next newline like this:

```
std::cin.ignore(std::numeric_limits<std::streamsize>::max(), '\n');

```