{"id":371,"date":"2016-03-31T20:30:30","date_gmt":"2016-03-31T11:30:30","guid":{"rendered":"http:\/\/www.onepage.co.kr\/wordpress\/?p=371"},"modified":"2016-04-01T00:20:33","modified_gmt":"2016-03-31T15:20:33","slug":"mssql-to-mysql","status":"publish","type":"post","link":"https:\/\/www.onepage.co.kr\/wordpress\/index.php\/2016\/03\/31\/mssql-to-mysql\/","title":{"rendered":"mssql to mysql conversion"},"content":{"rendered":"<p>mssql to mysql<\/p>\n<p><a href=\"http:\/\/www.mysqltutorial.org\/mysql-data-types.aspx\">http:\/\/www.mysqltutorial.org\/mysql-data-types.aspx<\/a><\/p>\n<p>1.\u00a0 isnull ==&gt; ifnull &#8212; \ucffc\ub9ac\uc5d0\uc11c\ub9cc \ubcc0\uacbd\ud574\uc57c.<\/p>\n<ol>\n<li>index.asp 224 chk_DAU_Count &gt; &#8220;0&#8221;\u00a0 \u00a0 \ub370\uc774\ud0c0 \ud0c0\uc785 \ubbf8\uc2a4\ub9e4\uce58 &#8211;&gt; csng<\/li>\n<li>getdate() ==&gt; now()<\/li>\n<li>top 3 ==&gt; limit 3 or limit 0, 3<\/li>\n<li>dbo.\u00a0 ==&gt; \uacf5\ubc31<\/li>\n<li>datediff(hh,ubb_indt,getdate())\u00a0 ==&gt; TIMESTAMPDIFF(HOUR, ubb_indt, now())<\/li>\n<li>convert(varchar(10),regdate,120)\u00a0 ==&gt; date_format(regdate,&#8217;%Y-%m-%d&#8217;)<\/li>\n<li>convert(varchar(10),regdate,112)\u00a0 ==&gt; date_format(regdate,&#8217;%Y%m%d&#8217;)<\/li>\n<li>view\uc5d0\uc11c &#8211;&gt; end if ;\u00a0 \uc138\ubbf8\ucf5c\ub860 \uc8fc\uc758<\/li>\n<li>db connection \ub2e4\uc218 &#8211;&gt; \ubaa8\ub450 \ucc3e\uc544 \ub300\uccb4 utf \ud3ec\ud568.<\/li>\n<li>with(nolock) ==&gt; \uacf5\ubc31 , (nolock) ==&gt;\uacf5\ubc31<\/li>\n<li>nCount from db return == &gt; \ud0c0\uc785 \uce90\uc2a4\ud305 csng<\/li>\n<li>\ud604\uc7ac \ubd80\ubaa8\uacbd\ub85c \uc0ac\uc6a9 \uc0c1\ud0dc\uc784 &#8212; &gt; \uc218\uc815 \ubcc0\uacbd \ud544\uc694<\/li>\n<li>mysql ltrim, rtrim \uc9c0\uc6d0\ub428<\/li>\n<li>exec sp_xx ==&gt; call sp_xx\u00a0 \ud504\ub85c\uc2dc\uc838 \ud638\ucd9c<\/li>\n<li>mysql \ubdf0\uc0dd\uc131\uc2dc from \uc808 \ub4a4 \uc11c\ube0c\ucffc\ub9ac\ub294 \uc0ac\uc6a9 \ubd88\uac00\ub2a5\ud558\ub2e4<\/li>\n<li>TIME_TO_SEC(TIMEDIFF(&#8216;2007-01-09 10:24:46&#8242;,&#8217;2007-01-09 10:23:46&#8217;))<\/li>\n<li>not in(select * frm table \u00a0 limt)\u00a0 ==&gt; This version of MySQL doesn&#8217;t yet support &#8216;LIMIT &amp; IN\/ALL\/ANY\/SOME subquery&#8217;<\/li>\n<li>select charindex(&#8216;st&#8217;,&#8217;myteststring&#8217;) \u00a0 0 \u00a0 ==&gt; SELECT INSTR(&#8216;myteststring&#8217;,&#8217;st&#8217;);\u00a0 1\u00a0 \uc778\ub371\uc2a4 \uc8fc\uc758<\/li>\n<\/ol>\n<p>mssql to mysql<\/p>\n<ol>\n<li>default &#8216;getdate()&#8217; &#8211;&gt; &#8216;000-000-000&#8217;\u00a0 ==&gt; \ub2e4\uc2dc \uc5b4\ud50c\uc5d0\uc11c now()\u00a0 \ucd94\uac00<\/li>\n<li>Visual Studio 2010 Tools for Office Runtime &#8212; mssql -&gt; \uc5d1\uc140 -&gt; mysql \ub85c convert<\/li>\n<li>mysql for excel<\/li>\n<\/ol>\n<p>mssql to mysql\u00a0 : exists<\/p>\n<p>IF EXISTS (SELECT 1 FROM Table WHERE FieldValue=&#8221;)<\/p>\n<p>BEGIN<\/p>\n<p>SELECT TableID FROM Table WHERE FieldValue=&#8221;<\/p>\n<p>END<\/p>\n<p>ELSE<\/p>\n<p>BEGIN<\/p>\n<p>INSERT INTO TABLE(FieldValue) VALUES(&#8221;)<\/p>\n<p>SELECT SCOPE_IDENTITY() AS TableID<\/p>\n<p>END<\/p>\n<p>&#8212; rewritten for MySQL<\/p>\n<p>IF (SELECT 1 = 1 FROM Table WHERE FieldValue=&#8221;) THEN<\/p>\n<p>BEGIN<\/p>\n<p>SELECT TableID FROM Table WHERE FieldValue=&#8221;;<\/p>\n<p>END;<\/p>\n<p>ELSE<\/p>\n<p>BEGIN<\/p>\n<p>INSERT INTO Table (FieldValue) VALUES(&#8221;);<\/p>\n<p>SELECT LAST_INSERT_ID() AS TableID;<\/p>\n<p>END;<\/p>\n<p>END IF;<\/p>\n<p>myql procedure<\/p>\n<p><a href=\"http:\/\/code.tutsplus.com\/articles\/an-introduction-to-stored-procedures-in-mysql-5--net-17843\">http:\/\/code.tutsplus.com\/articles\/an-introduction-to-stored-procedures-in-mysql-5&#8211;net-17843<\/a><\/p>\n<p>&nbsp;<\/p>\n<p>DELIMITER \/\/<\/p>\n<p>CREATE PROCEDURE GetOfficeByCountry(IN countryName VARCHAR(255))<\/p>\n<p>BEGIN<\/p>\n<p>SELECT *<\/p>\n<p>FROM offices<\/p>\n<p>WHERE country = countryName;<\/p>\n<p>END \/\/<\/p>\n<p>DELIMITER ;<\/p>\n<p>CALL GetOfficeByCountry(&#8216;USA&#8217;)<\/p>\n","protected":false},"excerpt":{"rendered":"<p>mssql to mysql http:\/\/www.mysqltutorial.org\/mysql-data-types.aspx 1.\u00a0 isnull ==&gt; ifnull &#8212; \ucffc\ub9ac\uc5d0\uc11c\ub9cc \ubcc0\uacbd\ud574\uc57c. index.asp 224 chk_DAU_Count &gt; &#8220;0&#8221;\u00a0 \u00a0 \ub370\uc774\ud0c0 \ud0c0\uc785 \ubbf8\uc2a4\ub9e4\uce58 &#8211;&gt; csng getdate() ==&gt; now() top 3 ==&gt; limit 3 or limit 0, 3 dbo.\u00a0 ==&gt; \uacf5\ubc31 datediff(hh,ubb_indt,getdate())\u00a0 ==&gt; TIMESTAMPDIFF(HOUR, ubb_indt, now()) convert(varchar(10),regdate,120)\u00a0 ==&gt; date_format(regdate,&#8217;%Y-%m-%d&#8217;) convert(varchar(10),regdate,112)\u00a0 ==&gt; date_format(regdate,&#8217;%Y%m%d&#8217;) view\uc5d0\uc11c &#8211;&gt; end if ;\u00a0 \uc138\ubbf8\ucf5c\ub860 \uc8fc\uc758 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3,5],"tags":[],"class_list":["post-371","post","type-post","status-publish","format-standard","hentry","category-mariadb-mysql","category-mssql"],"_links":{"self":[{"href":"https:\/\/www.onepage.co.kr\/wordpress\/index.php\/wp-json\/wp\/v2\/posts\/371","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.onepage.co.kr\/wordpress\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.onepage.co.kr\/wordpress\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.onepage.co.kr\/wordpress\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.onepage.co.kr\/wordpress\/index.php\/wp-json\/wp\/v2\/comments?post=371"}],"version-history":[{"count":5,"href":"https:\/\/www.onepage.co.kr\/wordpress\/index.php\/wp-json\/wp\/v2\/posts\/371\/revisions"}],"predecessor-version":[{"id":379,"href":"https:\/\/www.onepage.co.kr\/wordpress\/index.php\/wp-json\/wp\/v2\/posts\/371\/revisions\/379"}],"wp:attachment":[{"href":"https:\/\/www.onepage.co.kr\/wordpress\/index.php\/wp-json\/wp\/v2\/media?parent=371"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.onepage.co.kr\/wordpress\/index.php\/wp-json\/wp\/v2\/categories?post=371"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.onepage.co.kr\/wordpress\/index.php\/wp-json\/wp\/v2\/tags?post=371"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}