diff options
| author | David M. Syzdek <syzdek@bindlebinaries.com> | 2019-05-23 22:10:28 -0800 |
|---|---|---|
| committer | David M. Syzdek <syzdek@bindlebinaries.com> | 2019-05-23 22:10:28 -0800 |
| commit | 6c6c00ca209e8d5971b0aee817606af090f0bd2c (patch) | |
| tree | f1906b7109be4e1202fa7875651a6f91b51d3e92 /notes | |
| parent | 543eb7bb4e8fad6e0ae80eb63f50dc44fccbe2c7 (diff) | |
| download | scratchpad-6c6c00ca209e8d5971b0aee817606af090f0bd2c.tar.gz scratchpad-6c6c00ca209e8d5971b0aee817606af090f0bd2c.tar.bz2 scratchpad-6c6c00ca209e8d5971b0aee817606af090f0bd2c.tar.xz scratchpad-6c6c00ca209e8d5971b0aee817606af090f0bd2c.zip | |
updating query examples
Diffstat (limited to 'notes')
| -rw-r--r-- | notes/projects/radius/sql/ippool-queries.sql | 28 |
1 files changed, 14 insertions, 14 deletions
diff --git a/notes/projects/radius/sql/ippool-queries.sql b/notes/projects/radius/sql/ippool-queries.sql index 9a82fc6..d5ad3b9 100644 --- a/notes/projects/radius/sql/ippool-queries.sql +++ b/notes/projects/radius/sql/ippool-queries.sql | |||
| @@ -36,7 +36,7 @@ SELECT ip.address AS address, | |||
| 36 | AND ip.username LIKE lower( :'myUsername' ) | 36 | AND ip.username LIKE lower( :'myUsername' ) |
| 37 | AND nas.name LIKE lower( :'myNasName' ) | 37 | AND nas.name LIKE lower( :'myNasName' ) |
| 38 | AND pool.name LIKE lower( :'myPoolName' ) | 38 | AND pool.name LIKE lower( :'myPoolName' ) |
| 39 | AND netblock.assignable = TRUE | 39 | AND netblock.busyout = FALSE |
| 40 | ORDER BY ip.modified DESC, | 40 | ORDER BY ip.modified DESC, |
| 41 | ip.address ASC | 41 | ip.address ASC |
| 42 | LIMIT 1; | 42 | LIMIT 1; |
| @@ -58,7 +58,7 @@ SELECT ip.address AS address, | |||
| 58 | FROM ip | 58 | FROM ip |
| 59 | INNER JOIN netblock | 59 | INNER JOIN netblock |
| 60 | ON netblock.network >>= ip.address | 60 | ON netblock.network >>= ip.address |
| 61 | AND netblock.assignable IS TRUE | 61 | AND netblock.busyout IS FALSE |
| 62 | INNER JOIN region | 62 | INNER JOIN region |
| 63 | ON region.id = netblock.regionId | 63 | ON region.id = netblock.regionId |
| 64 | INNER JOIN pool | 64 | INNER JOIN pool |
| @@ -68,7 +68,7 @@ SELECT ip.address AS address, | |||
| 68 | WHERE ip.nasId IS NULL | 68 | WHERE ip.nasId IS NULL |
| 69 | AND nas.name LIKE lower( :'myNasName' ) | 69 | AND nas.name LIKE lower( :'myNasName' ) |
| 70 | AND pool.name LIKE lower( :'myPoolName' ) | 70 | AND pool.name LIKE lower( :'myPoolName' ) |
| 71 | AND netblock.assignable = TRUE | 71 | AND netblock.busyout = FALSE |
| 72 | ORDER BY ip.modified ASC, | 72 | ORDER BY ip.modified ASC, |
| 73 | ip.address ASC | 73 | ip.address ASC |
| 74 | LIMIT 1; | 74 | LIMIT 1; |
| @@ -93,12 +93,12 @@ SELECT ip.address AS address, | |||
| 93 | SELECT DISTINCT pool.name AS poolName, | 93 | SELECT DISTINCT pool.name AS poolName, |
| 94 | region.name AS regionName, | 94 | region.name AS regionName, |
| 95 | ip.address AS address, | 95 | ip.address AS address, |
| 96 | TRUE = ALL | 96 | TRUE = SOME |
| 97 | ( | 97 | ( |
| 98 | SELECT nb2.assignable | 98 | SELECT nb2.busyout |
| 99 | FROM netblock AS nb2 | 99 | FROM netblock AS nb2 |
| 100 | WHERE ip.address <<= nb2.network | 100 | WHERE ip.address <<= nb2.network |
| 101 | ) AS active, | 101 | ) AS busyout, |
| 102 | ( | 102 | ( |
| 103 | nasId IS NOT NULL | 103 | nasId IS NOT NULL |
| 104 | ) AS assigned, | 104 | ) AS assigned, |
| @@ -120,13 +120,13 @@ SELECT DISTINCT pool.name AS poolName, | |||
| 120 | SELECT DISTINCT pool.name AS poolName, | 120 | SELECT DISTINCT pool.name AS poolName, |
| 121 | region.name AS regionName, | 121 | region.name AS regionName, |
| 122 | ip.address AS address, | 122 | ip.address AS address, |
| 123 | NOT EXISTS | 123 | EXISTS |
| 124 | ( | 124 | ( |
| 125 | SELECT * | 125 | SELECT * |
| 126 | FROM netblock AS nb2 | 126 | FROM netblock AS nb2 |
| 127 | WHERE ip.address <<= nb2.network | 127 | WHERE ip.address <<= nb2.network |
| 128 | AND NOT nb2.assignable | 128 | AND nb2.busyout |
| 129 | ) AS active, | 129 | ) AS busyout, |
| 130 | ( | 130 | ( |
| 131 | nasId IS NOT NULL | 131 | nasId IS NOT NULL |
| 132 | ) AS assigned, | 132 | ) AS assigned, |
| @@ -150,11 +150,11 @@ SELECT DISTINCT pool.name AS poolName, | |||
| 150 | */ | 150 | */ |
| 151 | SELECT DISTINCT ip.address AS ipAddress, | 151 | SELECT DISTINCT ip.address AS ipAddress, |
| 152 | netblock.network AS network, | 152 | netblock.network AS network, |
| 153 | netblock.assignable AS active | 153 | netblock.busyout AS active |
| 154 | FROM ip | 154 | FROM ip |
| 155 | INNER JOIN netblock | 155 | INNER JOIN netblock |
| 156 | ON ip.address <<= netblock.network | 156 | ON ip.address <<= netblock.network |
| 157 | WHERE netblock.assignable = FALSE | 157 | WHERE netblock.busyout = TRUE |
| 158 | ORDER BY ipAddress; | 158 | ORDER BY ipAddress; |
| 159 | 159 | ||
| 160 | 160 | ||
| @@ -163,18 +163,18 @@ SELECT DISTINCT ip.address AS ipAddress, | |||
| 163 | */ | 163 | */ |
| 164 | SELECT DISTINCT netblock.regionId AS regionId, | 164 | SELECT DISTINCT netblock.regionId AS regionId, |
| 165 | ip.address AS ipAddress, | 165 | ip.address AS ipAddress, |
| 166 | netblock.assignable AS active | 166 | netblock.busyout AS busyout |
| 167 | FROM ip | 167 | FROM ip |
| 168 | INNER JOIN netblock | 168 | INNER JOIN netblock |
| 169 | ON ip.address <<= netblock.network | 169 | ON ip.address <<= netblock.network |
| 170 | WHERE netblock.assignable = TRUE | 170 | WHERE netblock.busyout = FALSE |
| 171 | AND ip.address NOT IN | 171 | AND ip.address NOT IN |
| 172 | ( | 172 | ( |
| 173 | SELECT address AS ipAddress | 173 | SELECT address AS ipAddress |
| 174 | FROM ip | 174 | FROM ip |
| 175 | INNER JOIN netblock | 175 | INNER JOIN netblock |
| 176 | ON ip.address <<= netblock.network | 176 | ON ip.address <<= netblock.network |
| 177 | AND netblock.assignable = FALSE | 177 | AND netblock.busyout = TRUE |
| 178 | ) | 178 | ) |
| 179 | ORDER BY ipAddress; | 179 | ORDER BY ipAddress; |
| 180 | 180 | ||
