I have a table with five fields, and I need to filter it to be unique first four fields, but in result table I need all five. My function is searching all rows in table that equals data written in the search field, and looks like that:
$query = "SELECT * FROM `$userstable` WHERE `name` LIKE '%inputName%' LIMIT 50;";
My table looks like this:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
provider art name serie file
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
AAA 327 music 12FH deal.wav
AAA 134 cowboy 943 cow.exe
AAA 327 music 12FH blackjack.omg
BBB 327 music 12FH deal.wav
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
In Result I want to see is something like this:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
provider art name serie file
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
AAA 327 music 12FH deal.wav
AAA 134 cowboy 943 cow.exe
BBB 327 music 12FH deal.wav
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
UPD: It doesn’t matter witch AAA string will be resulted AAA 327 music 12FH deal.wav or AAA 327 music 12FH blackjack.omg
Do you need GROUP BY clause:
MySql works with hidden fields, that means that your
filecolumn may be some of the group file values. If you are looking for a specific value you need an aggregate function ( max, min, group_concat, … ) or a subquery.