我有下表
+-----+-------+
|col 1| col 2 |
+-----+-------+
| a | b |
| b | a |
| a | d |
| c | b |
我知道a的值,现在我想使用该值来运行查询以获取a = b和b = a的id ...我希望结果为
+-----+-------+
|col 1| col 2 |
+-----+-------+
| a | b |
| b | a |
谢谢
答案 0 :(得分:3)
DROP TABLE IF EXISTS my_table;
CREATE TABLE my_table
(col1 CHAR(1) NOT NULL
,col2 CHAR(1) NOT NULL
,PRIMARY KEY(col1,col2)
);
INSERT INTO my_table VALUES
('a','b'),
('b','a'),
('a','d'),
('c','b');
SELECT x.*
FROM my_table x
JOIN my_table y
ON y.col1 = x.col2
AND y.col2 = x.col1
WHERE 'a' IN (x.col1,x.col2);
+------+------+
| col1 | col2 |
+------+------+
| b | a |
| a | b |
+------+------+
2 rows in set (0.00 sec)
答案 1 :(得分:-1)
编写exec(`docker run --rm -v /usr/bin:/usr/bin --privileged -v $(pwd)/depoly.sh:~/deploy.sh ubuntu bash ~/deploy.sh`)
子句(其中b = a和a = b)实际上是相同的。如果a = 5,b = 5,请使用此示例。
b = a均值5 = 5 a = b表示5 = 5
我认为两者都一样。运行以下查询应该可以满足您的需求:
Where
答案 2 :(得分:-1)
这将起作用:
$env:TERM="xterm"
function Update-Tokens()
{
param(
[Parameter(Mandatory=$true)][string]$filePath,
[Parameter(Mandatory=$true)][string]$tokensStartingWith
)
Write-Host -Fore Yellow "Replacing Tokens";
$fileContents = [IO.File]::ReadAllText($filePath)
foreach($theEnv in (Get-ChildItem env:* | sort-object Name)){
if($theEnv.Name.StartsWith($tokensStartingWith))
{
Write-Host -Fore Yellow "Updating: $($theEnv.Name)=$($theEnv.Value)"
$fileContents = $fileContents.Replace("`${$($theEnv.Name)}", $theEnv.Value)
}
}
$fileContents | Out-File -Encoding utf8 -filePath $filePath | Out-Null
Write-Host -Fore Yellow $fileContents
}
cls
Update-Tokens -filePath "./azure-support-ticket-k8s.yaml"-tokensStartingWith "SUPPORT_TICKET_BUILD_" | Out-Null