<?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>MySql &#8211; MaXEster Technologies  | Technical Blog</title>
	<atom:link href="https://www.maxester.com/blog/category/mysql/feed/" rel="self" type="application/rss+xml" />
	<link>https://www.maxester.com/blog</link>
	<description>Tutorials, Examples and Implementation code for Developers Help</description>
	<lastBuildDate>Mon, 17 Feb 2025 09:17:48 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>https://wordpress.org/?v=5.0.22</generator>
	<item>
		<title>Get a string after a specific substring by length in MySQl and SQL</title>
		<link>https://www.maxester.com/blog/2019/11/28/get-a-string-after-a-specific-substring-by-length-in-mysql-and-sql/</link>
		<comments>https://www.maxester.com/blog/2019/11/28/get-a-string-after-a-specific-substring-by-length-in-mysql-and-sql/#respond</comments>
		<pubDate>Thu, 28 Nov 2019 07:14:35 +0000</pubDate>
		<dc:creator><![CDATA[Bhaskar Chaudhary]]></dc:creator>
				<category><![CDATA[MySql]]></category>

		<guid isPermaLink="false">https://www.maxester.com/blog/?p=748</guid>
		<description><![CDATA[<p>For MySql Let us assume a Customers table with a CustomerName Column which contain string of Max Length 200. For Sql Server Let us assume a Customers table with a CustomerName Column which contain string of Max Length 200.</p>
<p>The post <a rel="nofollow" href="https://www.maxester.com/blog/2019/11/28/get-a-string-after-a-specific-substring-by-length-in-mysql-and-sql/">Get a string after a specific substring by length in MySQl and SQL</a> appeared first on <a rel="nofollow" href="https://www.maxester.com/blog">MaXEster Technologies  | Technical Blog</a>.</p>
]]></description>
				<content:encoded><![CDATA[
<p></p>



<p></p>



<h4>For MySql</h4>



<p>Let us assume a <code>Customers</code> table with a <code>CustomerName</code> Column which contain string of Max Length 200. </p>



<center>
<script async src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
<!-- Fads -->
<ins class="adsbygoogle fads"
     style="display:inline-block;"
     data-ad-client="ca-pub-3804472713147276"
     data-ad-slot="1267368188"></ins>
<script>
     (adsbygoogle = window.adsbygoogle || []).push({});
</script>
</center>




<pre class="wp-block-code"><code>//Column data

+-----+---------------------------------------------+
| id  | CustomerName                                |
+-----+---------------------------------------------+
| 1   | Alfreds Futterkiste                         |
| 2   | Ana Trujillo Emparedados y helados          |
| 3   | Antonio Moreno Taquería                     |
| 4   | Around the Horn                             |
| 5   | Berglunds snabbköp                          |
| 6   | Blauer See Delikatessen                     |
| 7   | Blondel père et fils                        |
| 8   | Bólido Comidas preparadas                   |
+-----+---------------------------------------------+</code></pre>



<pre class="wp-block-code"><code>SELECT
  CONCAT (
    SUBSTR(`Customers`.`CustomerName`, 1, 15),
    IF(
      LENGTH(`Customers`.`CustomerName`) > 15,
      '...',
      ''
    )
  ) as `name`
FROM
  `Customers`;</code></pre>



<pre class="wp-block-code"><code>//output

+-----+---------------------------------------------+
| id  | CustomerName                                |
+-----+---------------------------------------------+
| 1   | Alfreds Futterk...                          |
| 2   | Ana Trujillo Em...                          |
| 3   | Antonio Moreno ...                          |
| 4   | Around the Horn                             |
| 5   | Berglunds snabb...                          |
| 6   | Blauer See Deli...                          |
| 7   | Blondel père et...                          |
| 8   | Bólido Comidas ...                          |
+-----+---------------------------------------------+</code></pre>



<center>
<script async src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
<!-- Fads -->
<ins class="adsbygoogle fads"
     style="display:inline-block;"
     data-ad-client="ca-pub-3804472713147276"
     data-ad-slot="1267368188"></ins>
<script>
     (adsbygoogle = window.adsbygoogle || []).push({});
</script>
</center>




<h4>For Sql Server</h4>



<p>

Let us assume a <code>Customers</code> table with a <code>CustomerName</code> Column which contain string of Max Length 200. 

</p>



<pre class="wp-block-code"><code>//Column data

+-----+---------------------------------------------+
| id  | CustomerName                                |
+-----+---------------------------------------------+
| 1   | Alfreds Futterkiste                         |
| 2   | Ana Trujillo Emparedados y helados          |
| 3   | Antonio Moreno Taquería                     |
| 4   | Around the Horn                             |
| 5   | Berglunds snabbköp                          |
| 6   | Blauer See Delikatessen                     |
| 7   | Blondel père et fils                        |
| 8   | Bólido Comidas preparadas                   |
+-----+---------------------------------------------+</code></pre>



<pre class="wp-block-code"><code>SELECT
  SUBSTRING(CustomerName, 1, 15) + (
    CASE WHEN LEN(CustomerName) > 15 THEN '...' ELSE '' END
  )
FROM
  Customers;
</code></pre>



<pre class="wp-block-code"><code>//output

+-----+---------------------------------------------+
| id  | CustomerName                                |
+-----+---------------------------------------------+
| 1   | Alfreds Futterk...                          |
| 2   | Ana Trujillo Em...                          |
| 3   | Antonio Moreno ...                          |
| 4   | Around the Horn                             |
| 5   | Berglunds snabb...                          |
| 6   | Blauer See Deli...                          |
| 7   | Blondel père et...                          |
| 8   | Bólido Comidas ...                          |
+-----+---------------------------------------------+</code></pre>
<p>The post <a rel="nofollow" href="https://www.maxester.com/blog/2019/11/28/get-a-string-after-a-specific-substring-by-length-in-mysql-and-sql/">Get a string after a specific substring by length in MySQl and SQL</a> appeared first on <a rel="nofollow" href="https://www.maxester.com/blog">MaXEster Technologies  | Technical Blog</a>.</p>
]]></content:encoded>
			<wfw:commentRss>https://www.maxester.com/blog/2019/11/28/get-a-string-after-a-specific-substring-by-length-in-mysql-and-sql/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Find users within a distance by using Latitude, Longitude, and MySQL</title>
		<link>https://www.maxester.com/blog/2019/05/06/filter-record-with-location-radius-latlong/</link>
		<comments>https://www.maxester.com/blog/2019/05/06/filter-record-with-location-radius-latlong/#respond</comments>
		<pubDate>Mon, 06 May 2019 12:46:13 +0000</pubDate>
		<dc:creator><![CDATA[Bhaskar Chaudhary]]></dc:creator>
				<category><![CDATA[MySql]]></category>

		<guid isPermaLink="false">https://www.maxester.com/blog/?p=377</guid>
		<description><![CDATA[<p>For filter records, you need to latitude and longitude column in the table which you are using. For fetching data as per the lat-long you can use below query by passing latitude and longitude values in the comments. In this&#8230;</p>
<p><a href="https://www.maxester.com/blog/2019/05/06/filter-record-with-location-radius-latlong/" class="btn-more">Read More<span class="arrow-more">&#8594;</span></a></p>
<p>The post <a rel="nofollow" href="https://www.maxester.com/blog/2019/05/06/filter-record-with-location-radius-latlong/">Find users within a distance by using Latitude, Longitude, and MySQL</a> appeared first on <a rel="nofollow" href="https://www.maxester.com/blog">MaXEster Technologies  | Technical Blog</a>.</p>
]]></description>
				<content:encoded><![CDATA[
<p>

For filter records, you need to latitude and longitude column in the table which you are using. For fetching data as per the lat-long you can use below query by passing latitude and longitude values in the comments. 

</p>



<p>In this below query, the user table is used and there is 2 latitude and longitude. One is for the user and we will get it from the user and others commented we need to pass to fetch data of users as per that particular area.</p>



<center>
<script async src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
<!-- Fads -->
<ins class="adsbygoogle fads"
     style="display:inline-block;"
     data-ad-client="ca-pub-3804472713147276"
     data-ad-slot="1267368188"></ins>
<script>
     (adsbygoogle = window.adsbygoogle || []).push({});
</script>
</center>




<pre class="wp-block-code"><code>SELECT
  `users`.id,
  (
    3959 * acos(
      cos(radians('--Here--')) * cos(radians(`users`.latitude)) * cos(
        radians(`users`.longitude) - radians(--Longitude Here--)
      ) + sin(radians(--Latitude Here--)) * sin(radians(`users`.latitude))
    )
  ) AS distance
FROM
  `users`
HAVING
  `distance` &lt; 10
ORDER BY
  `distance` ASC
LIMIT
  50
LIMIT 50</code></pre>



<center>
<script async src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
<!-- Fads -->
<ins class="adsbygoogle fads"
     style="display:inline-block;"
     data-ad-client="ca-pub-3804472713147276"
     data-ad-slot="1267368188"></ins>
<script>
     (adsbygoogle = window.adsbygoogle || []).push({});
</script>
</center>




<p>In which limit also used. If you also want to use that&#8217;s ok if you not want limit you can remove that limit code to fetch all data. Also in this, we have used the order by distance so the nearby user&#8217;s data comes first and then far users.</p>
<p>The post <a rel="nofollow" href="https://www.maxester.com/blog/2019/05/06/filter-record-with-location-radius-latlong/">Find users within a distance by using Latitude, Longitude, and MySQL</a> appeared first on <a rel="nofollow" href="https://www.maxester.com/blog">MaXEster Technologies  | Technical Blog</a>.</p>
]]></content:encoded>
			<wfw:commentRss>https://www.maxester.com/blog/2019/05/06/filter-record-with-location-radius-latlong/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How To Select Different Column of data as one with Laravel and MySql?</title>
		<link>https://www.maxester.com/blog/2019/02/22/how-to-select-different-column-of-data-in-one-with-laravel-and-mysql/</link>
		<comments>https://www.maxester.com/blog/2019/02/22/how-to-select-different-column-of-data-in-one-with-laravel-and-mysql/#comments</comments>
		<pubDate>Fri, 22 Feb 2019 10:54:10 +0000</pubDate>
		<dc:creator><![CDATA[Bhaskar Chaudhary]]></dc:creator>
				<category><![CDATA[Laravel]]></category>
		<category><![CDATA[MySql]]></category>

		<guid isPermaLink="false">https://www.maxester.com/blogs/?p=314</guid>
		<description><![CDATA[<p>Laravel uses query builder to perform database operations so you don&#8217;t need to rewrite the query for different database Platform. Let us assume a table with three column called cert1, cer2 and cert3 First we need to select the column&#8230;</p>
<p><a href="https://www.maxester.com/blog/2019/02/22/how-to-select-different-column-of-data-in-one-with-laravel-and-mysql/" class="btn-more">Read More<span class="arrow-more">&#8594;</span></a></p>
<p>The post <a rel="nofollow" href="https://www.maxester.com/blog/2019/02/22/how-to-select-different-column-of-data-in-one-with-laravel-and-mysql/">How To Select Different Column of data as one with Laravel and MySql?</a> appeared first on <a rel="nofollow" href="https://www.maxester.com/blog">MaXEster Technologies  | Technical Blog</a>.</p>
]]></description>
				<content:encoded><![CDATA[
<p>Laravel uses query builder to perform database operations so you don&#8217;t need to rewrite the query for different database Platform.</p>



<p>Let us assume a table with three column called <strong>cert1</strong>, <strong>cer2</strong> and <strong>cert3</strong></p>



<p>First we need to select the column with a desired name and then Union all of them together with common name selected.</p>



<center>
<script async src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
<!-- Fads -->
<ins class="adsbygoogle fads"
     style="display:inline-block;"
     data-ad-client="ca-pub-3804472713147276"
     data-ad-slot="1267368188"></ins>
<script>
     (adsbygoogle = window.adsbygoogle || []).push({});
</script>
</center>




<pre class="wp-block-code"><code>$union1 = Info::whereNotNull('cert1')
->select('cert1 AS Certificate ')
->Where('cert1', 'like', $request->input('term') . '%');

$union2 = Info::whereNotNull('cert2'
)->select('cert2 AS Certificate ')
->Where('cert2', 'like', $request->input('term') . '%');

$union = Info::whereNotNull('cert3')
->select('cert3 AS Certificate ')
->Where('cert3', 'like', $request->input('term') . '%')
->union($union2)
->union($union1)
->groupby('union')->get();</code></pre>



<p>Here Certificate is the common selected. </p>



<p>To write the same query in sql:-</p>



<center>
<script async src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
<!-- Fads -->
<ins class="adsbygoogle fads"
     style="display:inline-block;"
     data-ad-client="ca-pub-3804472713147276"
     data-ad-slot="1267368188"></ins>
<script>
     (adsbygoogle = window.adsbygoogle || []).push({});
</script>
</center>




<pre class="wp-block-code"><code>SELECT a.`cert1` as Certificate FROM info as a 
UNION 
SELECT b.`cert2` as Certificate FROM info as b 
UNION 
SELECT c.`cert3` as Certificate FROM info as c</code></pre>
<p>The post <a rel="nofollow" href="https://www.maxester.com/blog/2019/02/22/how-to-select-different-column-of-data-in-one-with-laravel-and-mysql/">How To Select Different Column of data as one with Laravel and MySql?</a> appeared first on <a rel="nofollow" href="https://www.maxester.com/blog">MaXEster Technologies  | Technical Blog</a>.</p>
]]></content:encoded>
			<wfw:commentRss>https://www.maxester.com/blog/2019/02/22/how-to-select-different-column-of-data-in-one-with-laravel-and-mysql/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>
