mysqlsqoop

How to add multiple filters in Sqoop --where clause?


My sample RDBMS data has below entries

+--------+-----------+----------+-----------+
| custid | fisrtname | lastname | city      |
+--------+-----------+----------+-----------+
|      1 | Arun      | Kumar    | chennai   |
|      2 | srini     | vasan    | chennai   |
|      3 | vasu      | devan    | bangalore |
|      4 | mohamed   | imran    | hydrabad  |
|      5 | arun      | basker   | chennai   |
+--------+-----------+----------+-----------+

I am trying to sqoop all entries where city is chennai or banglore using --where clause.

sqoop import --connect jdbc:mysql://localhost:3306/testdb --username root --password cloud --table customermod -m 1 --where "city='chennai,banglore'" --delete-target-dir --target-dir /user/cloud/citydata

What am I doing wrong?


Solution

  • You only need one filter, IN, not =. Assuming this is being appended into a SQL query, you want

    city IN ('chennai' , 'bangalore')
    

    None of your rows have a literal string 'chennai,banglore'