查询MySQL ...选择多个结果

时间:2016-03-06 05:39:20

标签: php mysql

目前我正在使用

# collect excel process ids before and after new excel background process is started
$priorExcelProcesses = Get-Process -name "*Excel*" | % { $_.Id }
$Excel = New-Object -ComObject Excel.Application
$postExcelProcesses = Get-Process -name "*Excel*" | % { $_.Id }

# your code here (probably looping through the Excel document in some way

# try to gently quit
$Excel.Quit()
[System.Runtime.Interopservices.Marshal]::ReleaseComObject($Excel)

# otherwise allow stop-process to clean up
$postExcelProcesses | ? { $priorExcelProcesses -eq $null -or $priorExcelProcesses -notcontains $_ } | % { Stop-Process -Id $_ }

这个问题是这个查询将在我的数据库中为1个用户提供我提供的IP,因为它查看我的数据库并找到它的第一个结果它将停止查询并回显该单个用户名,我想要它返回附加到该IP的所有用户名。

2 个答案:

答案 0 :(得分:1)

将您的WHERE更改为:

WHERE result LIKE %val1% OR result LIKE %val2%

另一种适合PHP的方式:

$arguments= array('val1','val2');

//Escape arguments, trim, whatever before doing this
//Better use PDO or a similar, with prepared statements.
//query  
$qr = 'SELECT ... WHERE result IN ('.implode(',',$arguments).')';

答案 1 :(得分:0)

您可以交换列结果和变量$ arguments:

$query = "SELECT username FROM database WHERE '".$arguments."' LIKE '%' + result + '%'";