Liquibase where clause with sub query

Viewed 170

Is it possible to write sub query in liquibase without using the <sql> tag

Lets say we have the following tables:

Table Cars:
  CarID      int
  CarName    nvarchar(100)

Table Drivers:
  DriverID   int
  DriverName nvarchar(100)

Table CarDrivers:
  CarID      int
  DriverID   int

Example

<delete tableName="CarDrivers">
    <where>DriverID in select driver.DriverID from Drivers driver where driver.DriverName = 'John Doe'</where>
</delete>

Is it possible to compute such subquery as select driver.DriverID from Drivers driver where driver.DriverName = 'John Doe' inside a liquibase <where> tag?

1 Answers

I think you can try like this:

<delete tableName="CarDrivers">
    <where>driverId IN (SELECT driverId FROM Drivers WHERE driverName IN ('John', 'Jack'))</where>
</delete>
Related