user1807271
user1807271

Reputation: 1006

check if row has a particular value (perl,mysql)

I'm trying to identify if a row has the value '1' anywhere in it (AKA any column). Is there an easy way to do this without searching every column with fetchrow_array? I've included a small table I've been working with as an example.

mysql> select * from Case_Tracking;
+--------------------+---------+---------+----------+---------+----------+---------------+
| accession_number   | cyp2d6  | cyp2c19 | factorII | factorV | apoe     | vkorc1_cyp2c9 |
+--------------------+---------+---------+----------+---------+----------+---------------+
| AIB14-1116-0000453 | Luminex | Luminex | Hologic  |       1 | ABI 7500 | Genmark       |
| AIB14-1123-0000074 | NULL    | Luminex | Hologic  | Hologic | ABI 7500 | Genmark       |
+--------------------+---------+---------+----------+---------+----------+---------------+

Upvotes: 0

Views: 49

Answers (1)

ikegami
ikegami

Reputation: 386706

It would be better to search every column using SQL (WHERE accession_number = '1' OR cyp2d6 = '1' OR ...) since you'd only need to fetch matching results.

Upvotes: 2

Related Questions