I have a tables called goods
, that looks like this.
id | name | type |
1 | honda | car |
2 | bianci | bike |
3 | ferari | car |
4 | hurley | motor bike |
4 | bar | motor bike |
I am trying to get an associative array from this table, whereby the index of the array ought to be the type
and the value to be the name
. The final result should look something like this.
array("car"=>"honda", "bike"=>"bianci", "car"=>"ferrari", "motor bike"=>"hurley");
I tried SELECT name FROM goods AS type WHERE type IN ('car', 'bike', 'motor bike')
but still gives the result indexing type
for the array.