如何将字符串转换为整数并比较指定数字使用mysql?(how to convert string to integer and compare specify number use mysql?)
我使用sql获取
text
值,并将text
字符串转换为整数以比较相同的指定数字。 原谅我可怜的英语。 第1步,我使用这个sql获取text
值。(结果是'8000mAh','2000mAh')SELECT `product_id`, `text` FROM `jfw_product_attribute` WHERE `attribute_id` =3
第2步,我使用sql将
text
字符串转换为整数来比较相同的指定数字:(我删除了最后三个str'mAh')SELECT `product_id` , CASE WHEN cast( REVERSE( SUBSTRING( REVERSE( text ) , 4 ) ) as UNSIGNED int) <1000 THEN 1 WHEN 1000 <= cast( REVERSE( SUBSTRING( REVERSE( text ) , 4 ) ) as UNSIGNED int) <=2000 THEN 2 WHEN 2001 <= cast( REVERSE( SUBSTRING( REVERSE( text ) , 4 ) ) as UNSIGNED int) <=3000 THEN 3 WHEN 3001 <= cast( REVERSE( SUBSTRING( REVERSE( text ) , 4 ) ) as UNSIGNED int) <=4000 THEN 4 WHEN 4001 <= cast( REVERSE( SUBSTRING( REVERSE( text ) , 4 ) ) as UNSIGNED int) <=5000 THEN 5 WHEN 5001 <= cast( REVERSE( SUBSTRING( REVERSE( text ) , 4 ) ) as UNSIGNED int) <=8000 THEN 6 WHEN 8001 <= cast( REVERSE( SUBSTRING( REVERSE( text ) , 4 ) ) as UNSIGNED int) THEN 7 END AS `filter_id` FROM `jfw_product_attribute` WHERE `attribute_id` =3
我无法得到正确的
filter_id
,我只是得到所有filter_id
是2.Someone可以帮助我吗?非常感谢你。I use sql to get
text
value,and converttext
string to integer to compare same specify numbers. Forgive my poor English. Step 1,I use this sql gettext
value.(The result is Like '8000mAh','2000mAh')SELECT `product_id`, `text` FROM `jfw_product_attribute` WHERE `attribute_id` =3
Step 2,I use sql convert
text
string to integer to compare same specify numbers:(I delete the last three str 'mAh')SELECT `product_id` , CASE WHEN cast( REVERSE( SUBSTRING( REVERSE( text ) , 4 ) ) as UNSIGNED int) <1000 THEN 1 WHEN 1000 <= cast( REVERSE( SUBSTRING( REVERSE( text ) , 4 ) ) as UNSIGNED int) <=2000 THEN 2 WHEN 2001 <= cast( REVERSE( SUBSTRING( REVERSE( text ) , 4 ) ) as UNSIGNED int) <=3000 THEN 3 WHEN 3001 <= cast( REVERSE( SUBSTRING( REVERSE( text ) , 4 ) ) as UNSIGNED int) <=4000 THEN 4 WHEN 4001 <= cast( REVERSE( SUBSTRING( REVERSE( text ) , 4 ) ) as UNSIGNED int) <=5000 THEN 5 WHEN 5001 <= cast( REVERSE( SUBSTRING( REVERSE( text ) , 4 ) ) as UNSIGNED int) <=8000 THEN 6 WHEN 8001 <= cast( REVERSE( SUBSTRING( REVERSE( text ) , 4 ) ) as UNSIGNED int) THEN 7 END AS `filter_id` FROM `jfw_product_attribute` WHERE `attribute_id` =3
I cant get right
filter_id
,I just get allfilter_id
is 2.Someone can help me?Thank you very much.
原文:https://stackoverflow.com/questions/20735900
最满意答案
会话正在远程计算机上执行,我相信PowerShell期望文件存在。
我会尝试将本地脚本作为脚本块加载,以便它在内存中来接近它:
$thePath = 'D:\ServiceNow\RDC-Dev-All\agent\scripts\PowerShell' $theCommand = $thePath+"\ImMigration_script.ps1" $theCommand2 = [Scriptblock]::Create(Get-Content $theCommand)
然后,从你的问题:
Invoke-Command -Session $Session -ScriptBlock $theCommand2 -argumentlist $leName
如果有效,请告诉我。
The session is being executed on the remote computer, and I believe that's where PowerShell will expect the file to exist.
I would approach it by attempting to load the local script as a scriptblock so that it is in memory:
$thePath = 'D:\ServiceNow\RDC-Dev-All\agent\scripts\PowerShell' $theCommand = $thePath+"\ImMigration_script.ps1" $theCommand2 = [Scriptblock]::Create(Get-Content $theCommand)
Then, from your question:
Invoke-Command -Session $Session -ScriptBlock $theCommand2 -argumentlist $leName
Please let me know if this works.
相关问答
更多-
我认为这需要从Management Shell而不是控制台运行,这听起来像该模块没有被导入Powershell控制台。 您可以通过运行添加模块: Add-PSSnapin Microsoft.Sharepoint.Powershell 在Powershell控制台中。 I think this need to be run from the Management Shell rather than the console, it sounds like the module isn't being imp ...
-
术语“Set-AzureRmVMPlan”未被识别为cmdlet的名称(The term 'Set-AzureRmVMPlan' is not recognized as the name of a cmdlet)[2023-10-07]
那么在这里发生的事情,Azure自动化使用旧版本的模块,您必须转到Azure自动化刀片>资产>模块>浏览库并重新导入AzureRM.Profile和AzureRM.Compute。 So what is happening here, Azure Automation uses the old version of the Module, you have to go to Azure Automation Blade > Assets > Modules > Browse Gallery and reim ... -
我继续为你做了一些修改,使它看起来更干净并修正了括号(这是导致你得到的错误)。 随意问任何问题! 作为未来的参考资料,当您需要检查脚本是否有任何问题时,您可以将其复制并粘贴到PowerShell ISE中,这将是最容易的事情,它会强调它以红色显示的任何错误。 #Create log path $path = "D:\log\folder\location" If(!(test-path $path)){ New-Item -ItemType Directory -Force -Path $path ...
-
请参阅以下步骤: 添加PowerShell任务 脚本: Install-PackageProvider -Name NuGet -Force -Scope CurrentUser Get-Module -ListAvailable| where {$_.Name -Like "*AzureRM*"} | Select Name, Version Install-Module -Name AzureRM -RequiredVersion 6.0.1 -Force -Scope CurrentUser -Al ...
-
你可以尝试在PowerShell系统模块路径中安装OpenXmlPowerTools模块: C:\Windows\system32\WindowsPowerShell\v1.0\Modules Can you just try to install OpenXmlPowerTools module in the PowerShell System module path : C:\Windows\system32\WindowsPowerShell\v1.0\Modules
-
使用'cmd'而不是Powershell控制台。 也可以确定你的PATH环境变量中有Jmeter(文件夹安装)\ bin。 Use 'cmd' instead of the Powershell console. Also may sure that you have Jmeter(folder installation)\bin in your PATH environment variable.
-
由于命令行参数通过“运行”标记的方式,您需要转义GigaBytes周围的双引号(使用\ escape字符)或用单引号替换它们。 这两个Select-Object命令中的任何一个都应该起作用: Select-Object Name, @{Name=\"GigaBytes\";Expression={$_.Length / 1GB}} 要么 Select-Object Name, @{Name='GigaBytes';Expression={$_.Length / 1GB}} 这是因为用双引号括起来的任何内 ...
-
会话正在远程计算机上执行,我相信PowerShell期望文件存在。 我会尝试将本地脚本作为脚本块加载,以便它在内存中来接近它: $thePath = 'D:\ServiceNow\RDC-Dev-All\agent\scripts\PowerShell' $theCommand = $thePath+"\ImMigration_script.ps1" $theCommand2 = [Scriptblock]::Create(Get-Content $theCommand) 然后,从你的问题: I ...
-
在用户名行之前,我添加了这一行:“Import-Module DataOnTap”&Environment.NewLine&_ ** Right before the username line, I added this line: "Import-Module DataOnTap" & Environment.NewLine & _**
-
我相信cmdlet的名称应该是单数Set-AzureKeyVaultKeyAttribute ,而不是复数Set-AzureKeyVaultKeyAttributes 。 请注意,这是微软对PowerShell 强烈鼓励的开发指南之一: 为了增强用户体验,您为cmdlet名称选择的名词应该是单数。 例如,使用名称Get-Process而不是Get-Processes。 对于所有cmdlet名称,最好遵循此规则,即使cmdlet可能对多个项目起作用。 如果您在使用单数名称时仍然看到相同的问题,请确保已经安装并 ...