Helpful Information
Home
Categories
Contact us
Category: Databases
Checking if a row exists in mysql with perl
Is there an easy way in with perl and mysql to check to see if a row [value] exists?
If I do a 'prepare', 'execute' and 'fetch' and the row/value doesn't exist I get an error message and it fails, so....
At the moment I do a 'select count(*) from mytable where col = <value>' and check the result of the 'count).
Surely, there must be a more elegant way of doing it?
Forget that!
I only get the error when selecting 'NULL' values into my variable that I want to check..
I can do a 'if (not $mysel->fetch)....'
oops...
? yeah thanks for telling us what you did right. Helps a lot of others who have the same problem you had.
is that 'if (not $mysel->fetch)....' vague code php? perl?
privacy (GDPR)