If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > MySQL > run a query in batch file

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 09-13-04, 23:50
mickykt mickykt is offline
Registered User
 
Join Date: Mar 2003
Location: Singapore
Posts: 200
run a query in batch file

Hi,

I want to run a batch file that executes a command in SQL as select Count(*) from sometable;

when I edit the bat files as such it goes till the command prompt,but home to make the rest execute:

contents for BAT file:

mysql test;

select COunt(*) from a;

##############

It stops at the mysql > prompt.

Please help me to run the batch file.

Thanks

micky
Reply With Quote
  #2 (permalink)  
Old 09-14-04, 08:46
RBARAER RBARAER is offline
Registered User
 
Join Date: Aug 2004
Location: France
Posts: 754
Hello,

What you say seems normal to me : you execute "mysql test" on the OS prompt, which launches mysql, but from now on, you will not execute the rest of your batch until you get out of mysql. What you should do is, as said in the mysql manual, launching mysql with a sql script by doing so :

mysql db_name < script.sql > output.tab

or telling mysql to execute a statement, with something like this :

mysql --execute statement db_name

which in your case would be (not sure about the quotes) :

mysql --execute 'select Count(*) from a;' test

Regards,

RBARAER
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On