<?xml version="1.0" encoding="UTF-8"?><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/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>query &#8211; Database Research &amp; Development</title>
	<atom:link href="https://www.dbrnd.com/tag/query/feed/" rel="self" type="application/rss+xml" />
	<link>https://www.dbrnd.com</link>
	<description>BIGData &#124; NoSQL &#124; MSSQL &#124; MySQL &#124; PostgreSQL</description>
	<lastBuildDate>Fri, 22 Sep 2017 21:47:58 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=7.0.6</generator>
	<item>
		<title>MySQL: Query Interview Questions and Answers</title>
		<link>https://www.dbrnd.com/2015/10/mysql-query-interview-questions-and-answers/</link>
		
		<dc:creator><![CDATA[Anvesh Patel]]></dc:creator>
		<pubDate>Fri, 09 Oct 2015 19:10:35 +0000</pubDate>
				<category><![CDATA[MySQL]]></category>
		<category><![CDATA[MySQL Interview]]></category>
		<category><![CDATA[Anvesh Patel]]></category>
		<category><![CDATA[database]]></category>
		<category><![CDATA[database research and development]]></category>
		<category><![CDATA[dbrnd]]></category>
		<category><![CDATA[interview]]></category>
		<category><![CDATA[MySQL Command]]></category>
		<category><![CDATA[MySQL Database Administrator]]></category>
		<category><![CDATA[MySQL Database Designing]]></category>
		<category><![CDATA[MySQL Database Programming]]></category>
		<category><![CDATA[MySQL Error]]></category>
		<category><![CDATA[MySQL Performance Tunning]]></category>
		<category><![CDATA[MySQL Query]]></category>
		<category><![CDATA[MySQL Tips and Tricks]]></category>
		<category><![CDATA[practical]]></category>
		<category><![CDATA[query]]></category>
		<guid isPermaLink="false">https://www.dbrnd.com/?p=811</guid>

					<description><![CDATA[I require selecting 10 records at a time and at the same time I also require to know the total count of records. How would you do this? You can use SQL_CALC_FOUND_ROWS in SELECT statement and execute FOUND_ROWS(). Sample query: [crayon-6ab48871a0c4a833078688/] The First statement will return your 10 records and second statement will return total [&#8230;]]]></description>
										<content:encoded><![CDATA[<p><a class="a2a_button_facebook" href="https://www.addtoany.com/add_to/facebook?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2015%2F10%2Fmysql-query-interview-questions-and-answers%2F&amp;linkname=MySQL%3A%20Query%20Interview%20Questions%20and%20Answers" title="Facebook" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_twitter" href="https://www.addtoany.com/add_to/twitter?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2015%2F10%2Fmysql-query-interview-questions-and-answers%2F&amp;linkname=MySQL%3A%20Query%20Interview%20Questions%20and%20Answers" title="Twitter" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_linkedin" href="https://www.addtoany.com/add_to/linkedin?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2015%2F10%2Fmysql-query-interview-questions-and-answers%2F&amp;linkname=MySQL%3A%20Query%20Interview%20Questions%20and%20Answers" title="LinkedIn" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_pinterest" href="https://www.addtoany.com/add_to/pinterest?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2015%2F10%2Fmysql-query-interview-questions-and-answers%2F&amp;linkname=MySQL%3A%20Query%20Interview%20Questions%20and%20Answers" title="Pinterest" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_reddit" href="https://www.addtoany.com/add_to/reddit?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2015%2F10%2Fmysql-query-interview-questions-and-answers%2F&amp;linkname=MySQL%3A%20Query%20Interview%20Questions%20and%20Answers" title="Reddit" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_pocket" href="https://www.addtoany.com/add_to/pocket?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2015%2F10%2Fmysql-query-interview-questions-and-answers%2F&amp;linkname=MySQL%3A%20Query%20Interview%20Questions%20and%20Answers" title="Pocket" rel="nofollow noopener" target="_blank"></a><a class="a2a_dd addtoany_share_save addtoany_share" href="https://www.addtoany.com/share#url=https%3A%2F%2Fwww.dbrnd.com%2F2015%2F10%2Fmysql-query-interview-questions-and-answers%2F&#038;title=MySQL%3A%20Query%20Interview%20Questions%20and%20Answers" data-a2a-url="https://www.dbrnd.com/2015/10/mysql-query-interview-questions-and-answers/" data-a2a-title="MySQL: Query Interview Questions and Answers"></a></p><p><strong>I require selecting 10 records at a time and at the same time I also require to know the total count of records.</strong><br />
<strong>How would you do this?</strong></p>
<p>You can use SQL_CALC_FOUND_ROWS in SELECT statement and execute FOUND_ROWS().<br />
Sample query:</p><pre class="crayon-plain-tag">SELECT SQL_CALC_FOUND_ROWS * FROM Test LIMIT 10;
SELECT FOUND_ROWS();</pre><p>
The First statement will return your 10 records and second statement will return total count of records.<br />
The FOUND_ROWS() function will not internally use COUNT so it performs better.</p>
<p><strong>Find all database starting with &#8216;db&#8217;.</strong></p><pre class="crayon-plain-tag">SHOW DATABASES LIKE 'db%';</pre><p>
<p><strong>How to concatenate this two string?</strong></p>
<p><strong>String 1:</strong> &#8216;My name is Anvesh.&#8217;</p>
<p><strong>String 2:</strong> &#8216;I am Database Administrator.&#8217;</p><pre class="crayon-plain-tag">SELECT CONCAT('My name is Anvesh.',' I am Database Administrator.');</pre><p>
<p><strong>How to get a portion of a string by specifying position?</strong></p><pre class="crayon-plain-tag">SELECT SUBSTR('I am Anvesh Patel',6,6);</pre><p>
<p><strong>How to select month from given date?</strong></p><pre class="crayon-plain-tag">SELECT MONTH(NOW()); 
SELECT MONTHNAME(NOW());</pre><p>
<p><strong>How to format date in MM-DD-YY format?</strong></p><pre class="crayon-plain-tag">SELECT DATE_FORMAT(NOW(),'%m-%d-%y');</pre><p>
<p><strong>How to format date in week &#8211; day &#8211; month &#8211; year format?</strong></p><pre class="crayon-plain-tag">SELECT DATE_FORMAT(NOW(),'%W %D %M %Y');</pre><p>
<p><strong>How to copy the only table structure and create a new table?</strong></p><pre class="crayon-plain-tag">CREATE TABLE Test2 AS SELECT *FROM Test WHERE 1=2;</pre><p>
<p><strong>How to make copies of the table with data and structure?</strong></p><pre class="crayon-plain-tag">CREATE TABLE Test2 AS SELECT *FROM Test;</pre><p>
<p><strong>What are the result of below queries?<br />
</strong></p><pre class="crayon-plain-tag">SELECT NULL + 8 FROM DUAL;</pre><p>
Result : NULL</p><pre class="crayon-plain-tag">SELECT NULL OR TRUE FROM DUAL;</pre><p>
Result : 1</p><pre class="crayon-plain-tag">SELECT NULL AND TRUE FROM DUAL;</pre><p>
Result : NULL</p>
<p><strong>How to convert numeric values to strings?</strong></p><pre class="crayon-plain-tag">SELECT CAST(88.808 AS CHAR) FROM DUAL;</pre><p>
<p><strong>How to convert string values to Date format?</strong></p><pre class="crayon-plain-tag">SELECT STR_TO_DATE('08-Aug-2015 8:08:08', '%d-%b-%Y') FROM DUAL;</pre><p>
<p><strong>How to add new column to an existing table?</strong></p><pre class="crayon-plain-tag">ALTER TABLE test ADD COLUMN RecordDateTime DATETIME;</pre><p>
<p><strong>How to drop column from an existing table?</strong></p><pre class="crayon-plain-tag">ALTER TABLE test DROP COLUMN RecordDateTime;</pre><p>
<p><strong>How to rename a column in an existing table?</strong></p><pre class="crayon-plain-tag">ALTER TABLE Test CHANGE COLUMN OldColumnName NewColumnName INTEGER;</pre><p>
<p><strong>How to rename existing Table?</strong></p><pre class="crayon-plain-tag">ALTER TABLE Test rename to Test2;</pre><p>
<p><strong>How to drop index of a table?</strong></p><pre class="crayon-plain-tag">DROP INDEX idx_tbl_test_rno ON test;</pre><p>
<p><strong>Check running all MySQL Server Processes.</strong></p><pre class="crayon-plain-tag">mysqladmin -u root -p processlist</pre><p>
<p><strong>Command to shutdown MySQL.</strong></p><pre class="crayon-plain-tag">mysqladmin -u root -p shutdown</pre><p>
<p><strong>Check MySQL current version.</strong></p><pre class="crayon-plain-tag">mysqladmin -u root -p version</pre><p>
<p><strong>Check MySQL is running or not.</strong></p><pre class="crayon-plain-tag">mysqladmin -u root -p ping</pre><p>
<p><strong>How to list all databases from the MySQL Server?</strong></p><pre class="crayon-plain-tag">Show databases;</pre><p>
<p><strong>How to switch or use to a database?</strong></p><pre class="crayon-plain-tag">Use MyDatabase;</pre><p>
<p><strong>How to list all tables from the MySQL Server?</strong></p><pre class="crayon-plain-tag">Show tables;</pre><p>
<p><strong>How to see a description or definition of the Table?</strong></p><pre class="crayon-plain-tag">describe tablename;</pre><p>
<p><strong>How to find top N records for each group?</strong><br />
<a href="https://www.dbrnd.com/2015/08/find-top-n-records-for-each-group-in-mysql/" target="_blank">Please visit this post:</a></p>
<p><strong>How to arrange rows to columns Pivot table in MySQL?</strong><br />
<a href="https://www.dbrnd.com/2015/08/arrange-rows-to-columns-pivot-table-in-mysql/" target="_blank">Please visit this post:</a></p>
<p><strong>How to calculate Rank in MySQL Query?</strong><br />
<a href="https://www.dbrnd.com/2015/08/calculation-of-rank-in-mysql-query/" target="_blank">Please visit this post:</a></p>
<p><strong>How to write Insert-Update, merge statement in MySQL?</strong><br />
<a href="https://www.dbrnd.com/2015/08/insert-update-merge-statement-in-mysql/" target="_blank">Please visit this post:</a></p>
<p><strong>How to insert a record if not exists in MySQL?</strong><br />
<a href="https://www.dbrnd.com/2015/09/insert-ignore-if-not-exists-in-mysql/" target="_blank">Please visit this post:</a></p>
]]></content:encoded>
					
		
		
			</item>
	</channel>
</rss>
