I would like to execute a sql command in bash, and do something based on whether or not there was a result.
e.g.
$ LOOKUP=123; mysql -e \
'SELECT id FROM table WHERE id='$LOOKUP dbname \
&& echo "Row $LOOKUP exists"
|| echo "Row $LOOKUP does not exists"
I can think of bodges (e.g. testing for ZLS) but wondered if there was a clean way?
Best Answer
Try changing the query to force a value
Instead of
you can use
Here is bash script to use that new query
Here is an alternative
Give it a Try !!!