{"id":37,"date":"2010-05-26T16:56:50","date_gmt":"2010-05-26T16:56:50","guid":{"rendered":""},"modified":"2012-06-08T12:42:26","modified_gmt":"2012-06-08T04:42:26","slug":"sql-substring-function","status":"publish","type":"post","link":"https:\/\/matnet.my\/blog\/2010\/05\/sql-substring-function\/","title":{"rendered":"SQL Substring Function"},"content":{"rendered":"<p>The Substring function in SQL is used to grab a portion of the stored data. This function is called differently for the different databases:<\/p>\n<p>    * MySQL: SUBSTR(), SUBSTRING()<br \/>\n    * Oracle: SUBSTR()<br \/>\n    * SQL Server: SUBSTRING() <\/p>\n<p>Example : <\/p>\n<p>Let say u have 2 table from old db.<\/p>\n<p>Table1<br \/>\nuserid<br \/>\nname<\/p>\n<p>Table2<br \/>\nuserid<br \/>\npassword<\/p>\n<p>userid in table1 and userid in table2 is identical but  userid in table 1 start with letters T and userid in table 2 is not start with T<\/p>\n<p>for example.<\/p>\n<p>Table1<br \/>\nuserid      name<br \/>\n1               itik<br \/>\n2               ayam<br \/>\n3               kambing<br \/>\n4               bangau<\/p>\n<p>Table2<br \/>\nuserid      password<br \/>\nT1              ******<br \/>\nT2              ******<br \/>\nT3              ******<br \/>\nT4              ******<\/p>\n<p>so we need to use sql substring function to erase the T to make it identical.<\/p>\n<p>The query :<\/p>\n<p>[quote]Select table1.userid, table1.name, table2,password from table1, table2 WHERE table1.userid = SUBSTR(table2.userid, 2)[\/quote]<\/p>\n","protected":false},"excerpt":{"rendered":"<p>The Substring function in SQL is used to grab a portion of the stored data. This function is called differently &hellip; <a href=\"https:\/\/matnet.my\/blog\/2010\/05\/sql-substring-function\/\" class=\"more-link\">More <span class=\"screen-reader-text\">SQL Substring Function<\/span> <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3],"tags":[],"class_list":["post-37","post","type-post","status-publish","format-standard","hentry","category-www","standard"],"_links":{"self":[{"href":"https:\/\/matnet.my\/blog\/wp-json\/wp\/v2\/posts\/37","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/matnet.my\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/matnet.my\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/matnet.my\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/matnet.my\/blog\/wp-json\/wp\/v2\/comments?post=37"}],"version-history":[{"count":2,"href":"https:\/\/matnet.my\/blog\/wp-json\/wp\/v2\/posts\/37\/revisions"}],"predecessor-version":[{"id":61,"href":"https:\/\/matnet.my\/blog\/wp-json\/wp\/v2\/posts\/37\/revisions\/61"}],"wp:attachment":[{"href":"https:\/\/matnet.my\/blog\/wp-json\/wp\/v2\/media?parent=37"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/matnet.my\/blog\/wp-json\/wp\/v2\/categories?post=37"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/matnet.my\/blog\/wp-json\/wp\/v2\/tags?post=37"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}