<?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>python to mysql Archives -</title>
	<atom:link href="https://mitindia.in/tag/python-to-mysql/feed/" rel="self" type="application/rss+xml" />
	<link>https://mitindia.in/tag/python-to-mysql/</link>
	<description></description>
	<lastBuildDate>Thu, 31 Dec 2020 07:13:52 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.9.4</generator>

<image>
	<url>https://mitindia.in/wp-content/uploads/2023/03/cropped-android-chrome-512x512-1-32x32.png</url>
	<title>python to mysql Archives -</title>
	<link>https://mitindia.in/tag/python-to-mysql/</link>
	<width>32</width>
	<height>32</height>
</image> 
	<item>
		<title>Joins using Python and MySQL</title>
		<link>https://mitindia.in/joins-using-python-and-mysql/</link>
		
		<dc:creator><![CDATA[SKB]]></dc:creator>
		<pubDate>Thu, 31 Dec 2020 06:54:22 +0000</pubDate>
				<category><![CDATA[Artificial Intelligence]]></category>
		<category><![CDATA[Machine Learning]]></category>
		<category><![CDATA[python]]></category>
		<category><![CDATA[inner join]]></category>
		<category><![CDATA[python to mysql]]></category>
		<guid isPermaLink="false">http://www.mitindia.in/?p=1109</guid>

					<description><![CDATA[<p>MYSQL Joins with Python Inner join example to retrieve records from two table. Here are those two table: Now we will retrieve records from both tables based on regno column. Source code is:  # pip install mysql-connector import mysql.connector as sql # pip install pandas import pandas as pd db_connection = sql.connect(host='localhost', database='college_db', user='root', password='') [&#8230;]</p>
<p>The post <a href="https://mitindia.in/joins-using-python-and-mysql/">Joins using Python and MySQL</a> appeared first on <a href="https://mitindia.in"></a>.</p>
]]></description>
										<content:encoded><![CDATA[<h1>MYSQL Joins with Python</h1>
<p>Inner join example to retrieve records from two table.</p>
<p>Here are those two table:</p>
<p><img fetchpriority="high" decoding="async" class="alignnone wp-image-1110 size-full" src="http://www.mitindia.in/wp-content/uploads/2020/12/innerjoin_tab.png" alt="" width="821" height="242" srcset="https://mitindia.in/wp-content/uploads/2020/12/innerjoin_tab.png 821w, https://mitindia.in/wp-content/uploads/2020/12/innerjoin_tab-300x88.png 300w, https://mitindia.in/wp-content/uploads/2020/12/innerjoin_tab-768x226.png 768w" sizes="(max-width: 821px) 100vw, 821px" /></p>
<p>Now we will retrieve records from both tables based on regno column.</p>
<p><strong>Source code is: </strong></p>
<pre class="EnlighterJSRAW" data-enlighter-language="null"># pip install mysql-connector
import mysql.connector as sql
# pip install pandas
import pandas as pd

db_connection = sql.connect(host='localhost', database='college_db', user='root', password='')
db_cursor = db_connection.cursor()

ch = pd.read_sql('SELECT student_info.sname,course.title FROM student_info INNER JOIN course ON course.regno=student_info.regno', con=db_connection)
print(ch)
</pre>
<p><strong>Output of above code is :</strong></p>
<p><img decoding="async" class="alignnone wp-image-1111 size-full" src="http://www.mitindia.in/wp-content/uploads/2020/12/innerjoin.png" alt="" width="386" height="102" srcset="https://mitindia.in/wp-content/uploads/2020/12/innerjoin.png 386w, https://mitindia.in/wp-content/uploads/2020/12/innerjoin-300x79.png 300w" sizes="(max-width: 386px) 100vw, 386px" /></p>
<p>In the above example only two records are matching i.e. regno 1002 and 1008 hence inner join, where records are displayed based on matching entries in either side of the tables.</p>
<p>Another example on Inner join to know balance fee of a student.</p>
<p><em>First</em>, let us design tables as following :</p>
<p><img decoding="async" class="alignnone wp-image-1114 size-full" src="http://www.mitindia.in/wp-content/uploads/2020/12/fee_master.png" alt="" width="884" height="225" srcset="https://mitindia.in/wp-content/uploads/2020/12/fee_master.png 884w, https://mitindia.in/wp-content/uploads/2020/12/fee_master-300x76.png 300w, https://mitindia.in/wp-content/uploads/2020/12/fee_master-768x195.png 768w" sizes="(max-width: 884px) 100vw, 884px" /></p>
<p>Now we will retrieve records based on regno from both the tables.</p>
<p>Source code:</p>
<pre class="EnlighterJSRAW" data-enlighter-language="null"># pip install mysql-connector
import mysql.connector as sql

# pip install pandas
import pandas as pd 

db_connection = sql.connect(host='localhost', database='college_db', user='root', password='')
db_cursor = db_connection.cursor()

ch1 = pd.read_sql("SELECT * from fee_master where regno='1001' ", con=db_connection)
print("Fee Master Table ")
print("________________________________")
print(ch1)

ch2 = pd.read_sql("SELECT * from fee_det where regno='1001' ", con=db_connection)
print("Fee Detail Table")
print("________________________________")
print(ch2)

print("Inner Join to coorelate data")
print("________________________________")
ch3= pd.read_sql("select  fee_master.totfee-sum(fee_det.feeamt) as 'Balance fee' from fee_master INNER JOIN fee_det ON fee_master.regno = fee_det.regno where fee_master.regno='1001' GROUP BY fee_det.regno", con=db_connection)
print(ch3)
</pre>
<p><strong>Output of the above example is:</strong></p>
<p><img loading="lazy" decoding="async" class="alignnone wp-image-1115 " src="http://www.mitindia.in/wp-content/uploads/2020/12/checkbalance.png" alt="" width="369" height="342" srcset="https://mitindia.in/wp-content/uploads/2020/12/checkbalance.png 497w, https://mitindia.in/wp-content/uploads/2020/12/checkbalance-300x278.png 300w" sizes="(max-width: 369px) 100vw, 369px" /></p>
<p>&nbsp;</p>
<p><a class="a2a_button_whatsapp" href="https://www.addtoany.com/add_to/whatsapp?linkurl=https%3A%2F%2Fmitindia.in%2Fjoins-using-python-and-mysql%2F&amp;linkname=Joins%20using%20Python%20and%20MySQL" title="WhatsApp" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_facebook" href="https://www.addtoany.com/add_to/facebook?linkurl=https%3A%2F%2Fmitindia.in%2Fjoins-using-python-and-mysql%2F&amp;linkname=Joins%20using%20Python%20and%20MySQL" title="Facebook" 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%2Fmitindia.in%2Fjoins-using-python-and-mysql%2F&#038;title=Joins%20using%20Python%20and%20MySQL" data-a2a-url="https://mitindia.in/joins-using-python-and-mysql/" data-a2a-title="Joins using Python and MySQL"><img src="https://static.addtoany.com/buttons/favicon.png" alt="Share"></a></p><p>The post <a href="https://mitindia.in/joins-using-python-and-mysql/">Joins using Python and MySQL</a> appeared first on <a href="https://mitindia.in"></a>.</p>
]]></content:encoded>
					
		
		
			</item>
	</channel>
</rss>
