I have a table like
<table width="60%" border="0">
<tr>
<td>intId</td>
<td>tagname</td>
<td>cid</td>
<td>lid</td>
</tr>
<tr>
<td>1</td>
<td>chemis</td>
<td>5</td>
<td>0</td>
</tr>
<tr>
<td>2</td>
<td>hist</td>
<td>4</td>
<td>0</td>
</tr>
<tr>
<td>3</td>
<td>canada</td>
<td>0</td>
<td>9</td>
</tr>
<tr>
<td>4</td>
<td>chemis</td>
<td>6</td>
<td>0</td>
</tr>
<tr>
<td>5</td>
<td>chemis</td>
<td>9</td>
<td>2</td>
</tr>
<tr>
<td>6</td>
<td>hist</td>
<td>3</td>
<td>1</td>
</tr>
</table>
$srarchkey_arr = array('chemis','tes','loyal','hist','canada');
My output should be
<table width="60%" border="0">
<tr>
<td>Tag Name </td>
<td>cid</td>
<td>lid</td>
</tr>
<tr>
<td>Chemis</td>
<td>5,6,9</td>
<td>0,0,2</td>
</tr>
<tr>
<td>hist</td>
<td>4,3,</td>
<td>0,1</td>
</tr>
<tr>
<td>canada</td>
<td>0</td>
<td>9</td>
</tr>
</table>
i.e In my tags table i have lots of tags with cid and lid
I want to search the words which are in array $srarchkey_arr
. I want to search these tags and give the output as specified. I used the like query but it gives the out put as individual record. So i again use loops to concat the cid and lids.
Is this possible to do this with single query and loop. Is there any possibility to pass this like array or like in()
for strings.
Please help me. thanks
use this sql
SELECT tagname, group_concat(cid), group_concat(lid) from test.check group by tagname;