Hi,

I am familiar with shell script but not really have much experience. I am looking into a shell script that would do this

I have 2 tables

TableA

id name interest
----------------------------------------
TableB

id name

I have to create a shell script which copies all the id,name values from TableA and inserts them in TableB.

Is this possible? Any help is appreciated.

thanks

... I have to create a shell script which copies all the id,name values from TableA and inserts them in TableB.

Is this possible? Any help is appreciated.

thanks

To misquote an old TV show, "Of course it's possible; don't be ridiculous." :) And it's really trivial.

You could try something like:

mysql -u username -e 'insert into TableB select col1,col2 from TableA;'

You have to enter the password manually; if it needs to run unattended, you can include the '-p password' option on the command line.

thank you I got that. its working fine. How do I check if any error occurred during execution. If an error occurred I would like to do a different operation.

thank you I got that. its working fine. How do I check if any error occurred during execution. If an error occurred I would like to do a different operation.

mysql -u ...
if [ $? -eq 0 ]; then
  echo "Success"
else
  echo "Failure"
fi

what if i wanto use the mysql command"create database dbname" inside a shell script???hw shld i go abt it???

This article has been dead for over six months. Start a new discussion instead.