Reputation: 181
I am facing small problem to get value.
In my database value is 48,53,40 and I get value 48,40,53 as result. I want to compare both values and show output. Both are same value. Only sequence are different.
Can anyone help me????
Upvotes: 1
Views: 2795
Reputation: 4071
Use match-against
with boolean mode
and remember to put fulltext index on column to make the query fast.
such as-
select * from temp_new where match(b) against('+48 +53 +40' in boolean mode);
Upvotes: 2
Reputation: 2564
You should use array_diff instead of inventing your own.
http://php.net/manual/en/function.array-diff.php
Upvotes: 0
Reputation: 21975
I suppose you get those in a string.
You could explode the string, then use in_array()
:
<?php
$foo = '48,53,40';
$bar = '48,40,53';
function are_equal($foo, $bar, $separator = ','){
$foo = explode($separator, $foo);
$bar = explode($separator, $bar);
foreach($foo as $number){
if(!in_array($number, $bar)){
return FALSE;
}
}
return TRUE;
}
var_dump(are_equal($foo, $bar));
But of course a DB redesign would be healthy in this case!
Upvotes: 0