<?xml version="1.0" encoding="UTF-8"?>
<!-- generator="wordpress/2.0.6" -->
<rss version="2.0" 
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	>

<channel>
	<title>PHP MySql Web Hosting</title>
	<link>http://php-mysql.devsitehosting.com</link>
	<description>PHP and MySQL Web Development</description>
	<pubDate>Fri, 01 Jun 2007 14:46:24 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.0.6</generator>
	<language>en</language>
			<item>
		<title>Postprocess mysql&#8217;s output. 1.23.3 Discussion In non-interactive mode,</title>
		<link>http://php-mysql.devsitehosting.com/2007/06/01/postprocess-mysqls-output-1233-discussion-in-non-interactive-mode/</link>
		<comments>http://php-mysql.devsitehosting.com/2007/06/01/postprocess-mysqls-output-1233-discussion-in-non-interactive-mode/#comments</comments>
		<pubDate>Fri, 01 Jun 2007 14:46:24 +0000</pubDate>
		<dc:creator>webmaster</dc:creator>
		
		<category>MySQL Solutions</category>

		<guid isPermaLink="false">http://php-mysql.devsitehosting.com/2007/06/01/postprocess-mysqls-output-1233-discussion-in-non-interactive-mode/</guid>
		<description><![CDATA[]]></description>
			<content:encoded><![CDATA[]]></content:encoded>
			<wfw:commentRss>http://php-mysql.devsitehosting.com/2007/06/01/postprocess-mysqls-output-1233-discussion-in-non-interactive-mode/feed/</wfw:commentRss>
		</item>
		<item>
		<title>% mysql cookbook &gt; outputfile However, if you</title>
		<link>http://php-mysql.devsitehosting.com/2007/05/31/mysql-cookbook-outputfile-however-if-you/</link>
		<comments>http://php-mysql.devsitehosting.com/2007/05/31/mysql-cookbook-outputfile-however-if-you/#comments</comments>
		<pubDate>Fri, 01 Jun 2007 03:33:56 +0000</pubDate>
		<dc:creator>webmaster</dc:creator>
		
		<category>MySQL Solutions</category>

		<guid isPermaLink="false">http://php-mysql.devsitehosting.com/2007/05/31/mysql-cookbook-outputfile-however-if-you/</guid>
		<description><![CDATA[% mysql cookbook > outputfile    However, if you try to run mysql interactively with the output redirected, you won&#8217;t be able to  see what you&#8217;re typing, so generally in this case you&#8217;ll also take query input from a file (or  another program):   % mysql cookbook < inputfile > [...]]]></description>
			<content:encoded><![CDATA[<p>% mysql cookbook > outputfile    However, if you try to run mysql interactively with the output redirected, you won&#8217;t be able to  see what you&#8217;re typing, so generally in this case you&#8217;ll also take query input from a file (or  another program):   % mysql cookbook < inputfile > outputfile    You can also send query output to another program. For example, if you want to mail query  output to someone, you might do so like this:   % mysql cookbook < inputfile | mail paul    Note that because mysql runs non-interactively in that context, it produces tab-delimited  output, which the mail recipient may find more difficult to read than tabular output. Recipe   1.22 shows how to fix this problem.  1.22 Selecting Tabular or Tab-Delimited Query Output Format  1.22.1 Problem  mysql produces tabular output when you want tab-delimited output, or vice versa.   1.22.2 Solution  Select the desired format explicitly with the appropriate command-line option.   1.22.3 Discussion  When you use mysql non-interactively (such as to read queries from a file or to send results  into a pipe), it writes output in tab-delimited format by default. Sometimes it's desirable to  produce tabular output instead. For example, if you want to print or mail query results, tab- delimited output doesn't look very nice. Use the -t (or --table) option to produce tabular  output that is more readable:   % mysql -t cookbook < inputfile | lpr  % mysql -t cookbook < inputfile | mail paul    The inverse operation is to produce batch (tab-delimited) output in interactive mode. To do  this, use -B or --batch.   1.23 Specifying Arbitrary Output Column Delimiters  1.23.1 Problem  You want mysql to produce query output using a delimiter other than tab.   1.23.2 Solution   </p>
<p> Note: If you are looking for good and high quality web space to host and run your application check Lunarwebhost <a href="http://www.lunarwebhost.net">Cheap Web Hosting</a> services
</p>
]]></content:encoded>
			<wfw:commentRss>http://php-mysql.devsitehosting.com/2007/05/31/mysql-cookbook-outputfile-however-if-you/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Redirect mysql&#8217;s output or use a pipe. 1.21.3</title>
		<link>http://php-mysql.devsitehosting.com/2007/05/31/redirect-mysqls-output-or-use-a-pipe-1213/</link>
		<comments>http://php-mysql.devsitehosting.com/2007/05/31/redirect-mysqls-output-or-use-a-pipe-1213/#comments</comments>
		<pubDate>Thu, 31 May 2007 15:12:07 +0000</pubDate>
		<dc:creator>webmaster</dc:creator>
		
		<category>MySQL Solutions</category>

		<guid isPermaLink="false">http://php-mysql.devsitehosting.com/2007/05/31/redirect-mysqls-output-or-use-a-pipe-1213/</guid>
		<description><![CDATA[Redirect mysql&#8217;s output or use a pipe.   1.21.3 Discussion  mysql chooses its default output format according to whether you run it interactively or non-  interactively. Under interactive use, mysql normally sends its output to the terminal and writes   query results using tabular format:   mysql> SELECT * FROM [...]]]></description>
			<content:encoded><![CDATA[<p>Redirect mysql&#8217;s output or use a pipe.   1.21.3 Discussion  mysql chooses its default output format according to whether you run it interactively or non-  interactively. Under interactive use, mysql normally sends its output to the terminal and writes   query results using tabular format:   mysql> SELECT * FROM limbs;  +&#8212;&#8212;&#8212;&#8212;&#8211;+&#8212;&#8212;+&#8212;&#8212;+  | thing | legs | arms |  +&#8212;&#8212;&#8212;&#8212;&#8211;+&#8212;&#8212;+&#8212;&#8212;+    | human | 2 | 2 |  | insect | 6 | 0 |  | squid | 0 | 10 |  | octopus | 0 | 8 |  | fish | 0 | 0 |  | centipede | 100 | 0 |  | table | 4 | 0 |  | armchair | 4 | 2 |  | phonograph | 0 | 1 |  | tripod | 3 | 0 |  | Peg Leg Pete | 1 | 2 |   | space alien | NULL | NULL |  +&#8212;&#8212;&#8212;&#8212;&#8211;+&#8212;&#8212;+&#8212;&#8212;+  12 rows in set (0.00 sec)    In non-interactive mode (that is, when either the input or output is redirected), mysql writes   output in tab-delimited format:   % echo &#8220;SELECT * FROM limbs&#8221; | mysql cookbook  thing legs arms  human 2 2  insect 6 0  squid 0 10  octopus 0 8  fish 0 0  centipede 100 0  table 4 0  armchair 4 2  phonograph 0 1  tripod 3 0  Peg Leg Pete 1 2  space alien NULL NULL    However, in either context, you can select any of mysql&#8217;s output formats by using the   appropriate command-line options. This section describes how to send mysql output   somewhere other than the terminal. The next several sections discuss the various mysql   output formats and how to select them explicitly according to your needs when the default   format isn&#8217;t what you want.   To save output from mysql in a file, use your shell&#8217;s standard redirection capability:    </p>
<p> Note: If you are looking for good and high quality web space to host and run your application check Lunarwebhost <a href="http://www.lunarwebhost.net">Cheap Web Hosting</a> services
</p>
]]></content:encoded>
			<wfw:commentRss>http://php-mysql.devsitehosting.com/2007/05/31/redirect-mysqls-output-or-use-a-pipe-1213/feed/</wfw:commentRss>
		</item>
		<item>
		<title>[6] The &#8211;pager option is not available under</title>
		<link>http://php-mysql.devsitehosting.com/2007/05/30/6-the-pager-option-is-not-available-under/</link>
		<comments>http://php-mysql.devsitehosting.com/2007/05/30/6-the-pager-option-is-not-available-under/#comments</comments>
		<pubDate>Thu, 31 May 2007 05:42:45 +0000</pubDate>
		<dc:creator>webmaster</dc:creator>
		
		<category>MySQL Solutions</category>

		<guid isPermaLink="false">http://php-mysql.devsitehosting.com/2007/05/30/6-the-pager-option-is-not-available-under/</guid>
		<description><![CDATA[[6] The &#8211;pager option is not available under Windows.  % mysql &#8211;pager=/usr/bin/less    &#8211;pager by itself tells mysql to use your default pager, as specified in your PAGER environment  variable:   % mysql &#8211;pager    If your PAGER variable isn&#8217;t set, you must either define it or use [...]]]></description>
			<content:encoded><![CDATA[<p>[6] The &#8211;pager option is not available under Windows.  % mysql &#8211;pager=/usr/bin/less    &#8211;pager by itself tells mysql to use your default pager, as specified in your PAGER environment  variable:   % mysql &#8211;pager    If your PAGER variable isn&#8217;t set, you must either define it or use the first form of the command  to specify a pager program explicitly. To define PAGER, use the instructions in Recipe 1.9 for  setting environment variables.   Within a mysql session, you can turn paging on and off using P and n. P without an  argument enables paging using the program specified in your PAGER variable. P with an  argument enables paging using the argument as the name of the paging program:   mysql> P  PAGER set to /bin/more  mysql> P /usr/bin/less  PAGER set to /usr/bin/less  mysql> n  PAGER set to stdout    Output paging was introduced in MySQL 3.23.28.   Another way to deal with long result sets is to use a terminal program that allows you to scroll  back through previous output. Programs such as xterm for the X Window System, Terminal for  Mac OS X, MacSSH or BetterTelnet for Mac OS, or Telnet for Windows allow you to set the  number of output lines saved in the scrollback buffer. Under Windows NT, 2000, or XP, you  can set up a DOS window that allows scrollback using the following procedure:   1.  Open the Control Panel.  2.  Create a shortcut to the MS-DOS prompt by right clicking on the Console item and dragging the mouse to where you  want to place the shortcut (on the desktop, for example).  3.  Right click on the shortcut and select the Properties item from the menu that appears.  4.  Select the Layout tab in the resulting Properties window.  5.  Set the screen buffer height to the number of lines you want to save and click the OK button.  Now you should be able to launch the shortcut to get a scrollable DOS window that allows  output produced by commands in that window to be retrieved by using the scrollbar.   1.21 Sending Query Output to a File or to a Program  1.21.1 Problem  You want to send mysql output somewhere other than to your screen.   1.21.2 Solution   </p>
<p> Note: If you are looking for good and high quality web space to host and run your application check Lunarwebhost <a href="http://www.lunarwebhost.net">Cheap Web Hosting</a> services
</p>
]]></content:encoded>
			<wfw:commentRss>http://php-mysql.devsitehosting.com/2007/05/30/6-the-pager-option-is-not-available-under/feed/</wfw:commentRss>
		</item>
		<item>
		<title>+&#8212;&#8212;&#8212;-+ +&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;+ &#124; NOW( ) &#124; +&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;+ &#124;</title>
		<link>http://php-mysql.devsitehosting.com/2007/05/30/now/</link>
		<comments>http://php-mysql.devsitehosting.com/2007/05/30/now/#comments</comments>
		<pubDate>Wed, 30 May 2007 18:32:11 +0000</pubDate>
		<dc:creator>webmaster</dc:creator>
		
		<category>MySQL Solutions</category>

		<guid isPermaLink="false">http://php-mysql.devsitehosting.com/2007/05/30/now/</guid>
		<description><![CDATA[+&#8212;&#8212;&#8212;-+  +&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;+  &#124; NOW( ) &#124;  +&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;+  &#124; 2001-07-04 10:42:22 &#124;  +&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;+    1.18.4 See Also  By default, results generated by queries that are specified with -e are displayed in tabular  format if output goes to the terminal, and in tab-delimited format otherwise. To produce a [...]]]></description>
			<content:encoded><![CDATA[<p>+&#8212;&#8212;&#8212;-+  +&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;+  | NOW( ) |  +&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;+  | 2001-07-04 10:42:22 |  +&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;+    1.18.4 See Also  By default, results generated by queries that are specified with -e are displayed in tabular  format if output goes to the terminal, and in tab-delimited format otherwise. To produce a  different output style, see Recipe 1.22.   1.19 Using Copy and Paste as a mysql Input Source  1.19.1 Problem  You want to take advantage of your graphical user interface (GUI) to make mysql easier to  use.   1.19.2 Solution  Use copy and paste to supply mysql with queries to execute. In this way, you can take  advantage of your GUI&#8217;s capabilities to augment the terminal interface presented by mysql.   1.19.3 Discussion  Copy and paste is useful in a windowing environment that allows you to run multiple programs  at once and transfer information between them. If you have a document containing queries  open in a window, you can just copy the queries from there and paste them into the window in  which you&#8217;re running mysql. This is equivalent to typing the queries yourself, but often  quicker. For queries that you issue frequently, keeping them visible in a separate window can  be a good way to make sure they&#8217;re always at your fingertips and easily accessible.   1.20 Preventing Query Output from Scrolling off the Screen  1.20.1 Problem  Query output zooms off the top of your screen before you can see it.   1.20.2 Solution  Tell mysql to display output a page at a time, or run mysql in a window that allows scrollback.   1.20.3 Discussion  If a query produces many lines of output, normally they just scroll right off the top of the  screen. To prevent this, tell mysql to present output a page at a time by specifying the &#8211;pager  option.[6] &#8211;pager=program tells mysql to use a specific program as your pager:    </p>
<p> Note: If you are looking for good and high quality web space to host and run your application check Lunarwebhost <a href="http://www.lunarwebhost.net">PHP Web Hosting</a> services
</p>
]]></content:encoded>
			<wfw:commentRss>http://php-mysql.devsitehosting.com/2007/05/30/now/feed/</wfw:commentRss>
		</item>
		<item>
		<title>produces output consisting of semicolon-terminated SQL statements can</title>
		<link>http://php-mysql.devsitehosting.com/2007/05/30/produces-output-consisting-of-semicolon-terminated-sql-statements-can/</link>
		<comments>http://php-mysql.devsitehosting.com/2007/05/30/produces-output-consisting-of-semicolon-terminated-sql-statements-can/#comments</comments>
		<pubDate>Wed, 30 May 2007 08:12:03 +0000</pubDate>
		<dc:creator>webmaster</dc:creator>
		
		<category>MySQL Solutions</category>

		<guid isPermaLink="false">http://php-mysql.devsitehosting.com/2007/05/30/produces-output-consisting-of-semicolon-terminated-sql-statements-can/</guid>
		<description><![CDATA[produces output consisting of semicolon-terminated SQL statements can be used as an input  source for mysql. This can be useful in many ways. For example, the mysqldump utility is used  to generate database backups. It writes a backup as a set of SQL statements that recreate the  database, so to process mysqldump [...]]]></description>
			<content:encoded><![CDATA[<p>produces output consisting of semicolon-terminated SQL statements can be used as an input  source for mysql. This can be useful in many ways. For example, the mysqldump utility is used  to generate database backups. It writes a backup as a set of SQL statements that recreate the  database, so to process mysqldump output, you feed it to mysql. This means you can use the  combination of mysqldump and mysql to copy a database over the network to another MySQL  server:   [5] Under Windows, the equivalent would be the &#8220;useless use of type award&#8221;:  % mysqldump cookbook | mysql -h some.other.host.com cookbook    Program-generated SQL also can be useful when you need to populate a table with test data  but don&#8217;t want to write the INSERT statements by hand. Instead, write a short program that  generates the statements and send its output to mysql using a pipe:   % generate-test-data | mysql cookbook    1.17.4 See Also  mysqldump is discussed further in Chapter 10.   1.18 Specifying Queries on the Command Line  1.18.1 Problem  You want to specify a query directly on the command line for mysql to execute.   1.18.2 Solution  mysql can read a query from its argument list. Use the -e (or &#8211;execute) option to specify a  query on the command line.   1.18.3 Discussion  For example, to find out how many records are in the limbs table, run this command:   % mysql -e &#8220;SELECT COUNT(*) FROM limbs&#8221; cookbook  +&#8212;&#8212;&#8212;-+  | COUNT(*) |  +&#8212;&#8212;&#8212;-+  | 12 |  +&#8212;&#8212;&#8212;-+    To run multiple queries with the -e option, separate them with semicolons:   % mysql -e &#8220;SELECT COUNT(*) FROM limbs;SELECT NOW( )&#8221; cookbook  +&#8212;&#8212;&#8212;-+  | COUNT(*) |  +&#8212;&#8212;&#8212;-+  | 12 |     </p>
<p> Note: If you are looking for good and high quality web space to host and run your application check Lunarwebhost <a href="http://www.lunarwebhost.net">MySQL Web Hosting</a> services
</p>
]]></content:encoded>
			<wfw:commentRss>http://php-mysql.devsitehosting.com/2007/05/30/produces-output-consisting-of-semicolon-terminated-sql-statements-can/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Then create a script file loop.sql that contains</title>
		<link>http://php-mysql.devsitehosting.com/2007/05/29/then-create-a-script-file-loopsql-that-contains/</link>
		<comments>http://php-mysql.devsitehosting.com/2007/05/29/then-create-a-script-file-loopsql-that-contains/#comments</comments>
		<pubDate>Tue, 29 May 2007 22:12:40 +0000</pubDate>
		<dc:creator>webmaster</dc:creator>
		
		<category>MySQL Solutions</category>

		<guid isPermaLink="false">http://php-mysql.devsitehosting.com/2007/05/29/then-create-a-script-file-loopsql-that-contains/</guid>
		<description><![CDATA[Then create a script file loop.sql that contains the following lines (be sure each line ends with a  semicolon):   UPDATE counter SET depth = depth + 1;  SELECT depth FROM counter;  SOURCE loop.sql;    Finally, invoke mysql and issue a SOURCE command to read the script file:  [...]]]></description>
			<content:encoded><![CDATA[<p>Then create a script file loop.sql that contains the following lines (be sure each line ends with a  semicolon):   UPDATE counter SET depth = depth + 1;  SELECT depth FROM counter;  SOURCE loop.sql;    Finally, invoke mysql and issue a SOURCE command to read the script file:   % mysql cookbook  mysql> SOURCE loop.sql;    The first two statements in loop.sql increment the nesting counter and display the current  depth value. In the third statement, loop.sql sources itself, thus creating an input loop. You&#8217;ll  see the output whiz by, with the counter display incrementing each time through the loop.  Eventually mysql will run out of file descriptors and stop with an error:   ERROR:  Failed to open file &#8216;loop.sql&#8217;, error: 24    What is error 24? Find out by using MySQL&#8217;s perror (print error) utility:   % perror 24  Error code 24: Too many open files    1.17 Telling mysql to Read Queries from Other Programs  1.17.1 Problem  You want to shove the output from another program into mysql.   1.17.2 Solution  Use a pipe.   1.17.3 Discussion  An earlier section used the following command to show how mysql can read SQL statements  from a file:   % mysql cookbook < limbs.sql    mysql can also read a pipe, to receive output from other programs as its input. As a trivial  example, the preceding command is equivalent to this one:   % cat limbs.sql | mysql cookbook    Before you tell me that I've qualified for this week's "useless use of cat award,"[5] allow me to  observe that you can substitute other commands for cat. The point is that any command that    </p>
<p> Note: If you are looking for good and high quality web space to host and run your application check Lunarwebhost <a href="http://www.lunarwebhost.net">Cheap Web Hosting</a> services
</p>
]]></content:encoded>
			<wfw:commentRss>http://php-mysql.devsitehosting.com/2007/05/29/then-create-a-script-file-loopsql-that-contains/feed/</wfw:commentRss>
		</item>
		<item>
		<title>INSERT INTO limbs (thing,legs,arms) VALUES(&#8217;tripod&#8217;,3,0); INSERT INTO limbs</title>
		<link>http://php-mysql.devsitehosting.com/2007/05/29/insert-into-limbs-thinglegsarms-valuestripod30-insert-into-limbs/</link>
		<comments>http://php-mysql.devsitehosting.com/2007/05/29/insert-into-limbs-thinglegsarms-valuestripod30-insert-into-limbs/#comments</comments>
		<pubDate>Tue, 29 May 2007 10:44:58 +0000</pubDate>
		<dc:creator>webmaster</dc:creator>
		
		<category>MySQL Solutions</category>

		<guid isPermaLink="false">http://php-mysql.devsitehosting.com/2007/05/29/insert-into-limbs-thinglegsarms-valuestripod30-insert-into-limbs/</guid>
		<description><![CDATA[INSERT INTO limbs (thing,legs,arms) VALUES(&#8217;tripod&#8217;,3,0);  INSERT INTO limbs (thing,legs,arms) VALUES(&#8217;Peg Leg Pete&#8217;,1,2);  INSERT INTO limbs (thing,legs,arms) VALUES(&#8217;space alien&#8217;,NULL,NULL);    To execute the statements in this SQL script file in batch mode, change directory into the   tables directory of the recipes distribution where the table-creation scripts are located, then  [...]]]></description>
			<content:encoded><![CDATA[<p>INSERT INTO limbs (thing,legs,arms) VALUES(&#8217;tripod&#8217;,3,0);  INSERT INTO limbs (thing,legs,arms) VALUES(&#8217;Peg Leg Pete&#8217;,1,2);  INSERT INTO limbs (thing,legs,arms) VALUES(&#8217;space alien&#8217;,NULL,NULL);    To execute the statements in this SQL script file in batch mode, change directory into the   tables directory of the recipes distribution where the table-creation scripts are located, then   run this command:   % mysql cookbook < limbs.sql    You'll note that the script contains a statement to drop the table if it exists before creating it   anew and loading it with data. That allows you to experiment with the table without worrying   about changing its contents, because you can restore the table to its baseline state any time   by running the script again.   The command just shown illustrates how to specify an input file for mysql on the command   line. As of MySQL 3.23.9, you can read a file of SQL statements from within a mysql session   by using a SOURCE filename command (or . filename, which is synonymous). Suppose   the SQL script file test.sql contains the following statements:   SELECT NOW( );  SELECT COUNT(*) FROM limbs;    You can execute that file from within mysql as follows:   mysql> SOURCE test.sql;  +&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;+  | NOW( ) |  +&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;+  | 2001-07-04 10:35:08 |  +&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;+  1 row in set (0.00 sec)  +&#8212;&#8212;&#8212;-+  | COUNT(*) |  +&#8212;&#8212;&#8212;-+  | 12 |  +&#8212;&#8212;&#8212;-+  1 row in set (0.01 sec)    SQL scripts can themselves include SOURCE or . commands to include other scripts. The   danger of this is that it&#8217;s possible to create a source loop. Normally you should take care to   avoid such loops, but if you&#8217;re feeling mischievous and want to create one deliberately to find   out how deep mysql can nest input files, here&#8217;s how to do it. First, issue the following two   statements manually to create a counter table to keep track of the source file depth and   initialize the nesting level to zero:   mysql> CREATE TABLE counter (depth INT);  mysql> INSERT INTO counter SET depth = 0;     </p>
<p> Note: If you are looking for good and high quality web space to host and run your application check Lunarwebhost <a href="http://www.lunarwebhost.net">PHP MySQL Web Hosting</a> services
</p>
]]></content:encoded>
			<wfw:commentRss>http://php-mysql.devsitehosting.com/2007/05/29/insert-into-limbs-thinglegsarms-valuestripod30-insert-into-limbs/feed/</wfw:commentRss>
		</item>
		<item>
		<title>By default, the mysql program reads input interactively</title>
		<link>http://php-mysql.devsitehosting.com/2007/05/28/by-default-the-mysql-program-reads-input-interactively/</link>
		<comments>http://php-mysql.devsitehosting.com/2007/05/28/by-default-the-mysql-program-reads-input-interactively/#comments</comments>
		<pubDate>Tue, 29 May 2007 00:09:00 +0000</pubDate>
		<dc:creator>webmaster</dc:creator>
		
		<category>MySQL Solutions</category>

		<guid isPermaLink="false">http://php-mysql.devsitehosting.com/2007/05/28/by-default-the-mysql-program-reads-input-interactively/</guid>
		<description><![CDATA[By default, the mysql program reads input interactively from the terminal, but you can feed it  queries in batch mode using other input sources such as a file, another program, or the  command arguments. You can also use copy and paste as a source of query input. This section  discusses how to [...]]]></description>
			<content:encoded><![CDATA[<p>By default, the mysql program reads input interactively from the terminal, but you can feed it  queries in batch mode using other input sources such as a file, another program, or the  command arguments. You can also use copy and paste as a source of query input. This section  discusses how to read queries from a file. The next few sections discuss how to take input  from other sources.   To create a SQL script for mysql to execute in batch mode, put your statements in a text file,  then invoke mysql and redirect its input to read from that file:   % mysql cookbook < filename    Statements that are read from an input file substitute for what you'd normally type in by  hand, so they must be terminated with semicolons (or g), just as if you were entering them  manually. One difference between interactive and batch modes is the default output style. For  interactive mode, the default is tabular (boxed) format. For batch mode, the default is to  delimit column values with tabs. However, you can select whichever output style you want  using the appropriate command-line options. See the section on selecting tabular or tab- delimited format later in the chapter (Recipe 1.22).   Batch mode is convenient when you need to issue a given set of statements on multiple  occasions, because then you need not enter them manually each time. For example, batch  mode makes it easy to set up cron jobs that run with no user intervention. SQL scripts are  also useful for distributing queries to other people. Many of the examples shown in this book  can be run using script files that are available as part of the accompanying recipes source  distribution (see Appendix A). You can feed these files to mysql in batch mode to avoid typing  queries yourself. A common instance of this is that when an example shows a CREATE TABLE  statement that describes what a particular table looks like, you'll find a SQL batch file in the  distribution that can be used to create (and perhaps load data into) the table. For example,  earlier in the chapter, statements for creating and populating the limbs table were shown.   The recipes distribution includes a file limbs.sql that contains statements to do the same  thing. The file looks like this:   DROP TABLE IF EXISTS limbs;  CREATE TABLE limbs    (  thing VARCHAR(20), # what the thing is  legs INT, # number of legs it has  arms INT # number of arms it has  );   INSERT INTO limbs (thing,legs,arms) VALUES('human',2,2);  INSERT INTO limbs (thing,legs,arms) VALUES('insect',6,0);  INSERT INTO limbs (thing,legs,arms) VALUES('squid',0,10);  INSERT INTO limbs (thing,legs,arms) VALUES('octopus',0,8);  INSERT INTO limbs (thing,legs,arms) VALUES('fish',0,0);  INSERT INTO limbs (thing,legs,arms) VALUES('centipede',100,0);  INSERT INTO limbs (thing,legs,arms) VALUES('table',4,0);  INSERT INTO limbs (thing,legs,arms) VALUES('armchair',4,2);  INSERT INTO limbs (thing,legs,arms) VALUES('phonograph',0,1);     </p>
<p> Note: If you are looking for good and high quality web space to host and run your application check Lunarwebhost <a href="http://www.lunarwebhost.net">MySQL Web Hosting</a> services
</p>
]]></content:encoded>
			<wfw:commentRss>http://php-mysql.devsitehosting.com/2007/05/28/by-default-the-mysql-program-reads-input-interactively/feed/</wfw:commentRss>
		</item>
		<item>
		<title>+&#8212;&#8212;&#8211;+ To set a variable explicitly to a</title>
		<link>http://php-mysql.devsitehosting.com/2007/05/28/to-set-a-variable-explicitly-to-a/</link>
		<comments>http://php-mysql.devsitehosting.com/2007/05/28/to-set-a-variable-explicitly-to-a/#comments</comments>
		<pubDate>Mon, 28 May 2007 12:39:45 +0000</pubDate>
		<dc:creator>webmaster</dc:creator>
		
		<category>MySQL Solutions</category>

		<guid isPermaLink="false">http://php-mysql.devsitehosting.com/2007/05/28/to-set-a-variable-explicitly-to-a/</guid>
		<description><![CDATA[+&#8212;&#8212;&#8211;+    To set a variable explicitly to a particular value, use a SET statement. SET syntax uses =   rather than := to assign the value:   mysql> SET @sum = 4 + 7;  mysql> SELECT @sum;  +&#8212;&#8212;+  &#124; @sum &#124;  +&#8212;&#8212;+  &#124; 11 &#124; [...]]]></description>
			<content:encoded><![CDATA[<p>+&#8212;&#8212;&#8211;+    To set a variable explicitly to a particular value, use a SET statement. SET syntax uses =   rather than := to assign the value:   mysql> SET @sum = 4 + 7;  mysql> SELECT @sum;  +&#8212;&#8212;+  | @sum |  +&#8212;&#8212;+  | 11 |  +&#8212;&#8212;+    A given variable&#8217;s value persists until you assign it another value or until the end of your   mysql session, whichever comes first.   Variable names are case sensitive:   mysql> SET @x = 1; SELECT @x, @X;  +&#8212;&#8212;+&#8212;&#8212;+  | @x | @X |  +&#8212;&#8212;+&#8212;&#8212;+  | 1 | NULL |  +&#8212;&#8212;+&#8212;&#8212;+    SQL variables can be used only where expressions are allowed, not where constants or literal   identifiers must be provided. Although it&#8217;s tempting to attempt to use variables for such things   as table names, it doesn&#8217;t work. For example, you might try to generate a temporary table   name using a variable as follows, but the result is only an error message:   mysql> SET @tbl_name = CONCAT(&#8217;tbl_&#8217;,FLOOR(RAND( )*1000000));  mysql> CREATE TABLE @tbl_name (int_col INT);  ERROR 1064 at line 2: You have an error in your SQL syntax near &#8216;@tbl_name  (int_col INT)&#8217; at line 1    SQL variables are a MySQL-specific extension, so they will not work with other database   engines.   1.16 Telling mysql to Read Queries from a File  1.16.1 Problem  You want mysql to read queries stored in a file so you don&#8217;t have to enter them manually.   1.16.2 Solution  Redirect mysql&#8217;s input or use the SOURCE command.   1.16.3 Discussion   </p>
<p> Note: If you are looking for good and high quality web space to host and run your application check Lunarwebhost <a href="http://www.lunarwebhost.net">PHP Web Hosting</a> services
</p>
]]></content:encoded>
			<wfw:commentRss>http://php-mysql.devsitehosting.com/2007/05/28/to-set-a-variable-explicitly-to-a/feed/</wfw:commentRss>
		</item>
	</channel>
</rss>
