MySql

Update Multiple Tables with one Statement

In real time applications there might be situation where you need update details of one table using details of another or update two or tables using one statement. Below is Example of how you can do that in SQL Server

Update t1 Set t1.col1 = t2.col1 from Table t1 inner join Table t2 on t1.col = t2.col where Condtn

Below is MYSql Example

Update Table t1 inner join Table t2 on t1.col = t2.col Set t1.col1 = t2.col1 where Condtn

Migrating from MS SQL Server to MYSQL

Migrating from MS SQL to MYSQL is a big pain. there are no good tools to use for migration of the all the datbase objects, right from tables , data to stored procedures. We all know that Microsoft SQL server has a very good User Interface but when we come back to MYSQL we donot enjoy the same previlages as we do in SQL server.

Coming to the tools available to download for a good GUI, we have very less options, MYSQL query , PHPadmin are some of them. There are some tools which can be used to migrate the tables and data from the MSSQL to MYSQL. The MYSQL migration tool is also available to migrate the tables. But iam not sure that we can also migrate the stored procedures, but when i tried to migrate a small application i totally failed to shift the stored procedures to MYSQL. I have to migrate them manually. I have to check the syntax manually for each and every line and then execute the procedure.
There are some points which we have to keep in mind while migrating the database from MSSQL to MYSQL. The MYSQL statements has to end with semi-colon , even the ending of the for loop has to closed by a semi-colon.

When we migrate the tables from MSSQL to MYSQL we do not get the perfect script which defines the primary keys and the default values. We have to turn them on manually.

So please be carefull while doing the application and choosing the database, the migration of the database is same as a small project. :)

wish you happy programmin


Get Number of Days in a Month Function

This article shows the ways to get the number of days in a month in both sqlserver and mysql.

Getting the number of days in a month is quite easy because it is going to be either 30 or 31 days, with the exception of February, which can either have 28 or 29 days depending if it is a leap year or not.

  • January,March,May,July,August,October,December — 31 Days
  • April,June,September,November – 30 Days
  • February – 28 Days (Non Leap Year), 29 (Leap Year)

Leap year should be divisible by 4, should not be divisible by 100 or should be divisible by 400.

(continue reading…)


A few maximum limitations for Sqlserver and MySql

Often people in newsgroups ask about maximum size of various objects defined in databases.

The following tables shows the maximum sizes and numbers of various objects defined in MYSql, SQL Server.


MySql Maximums
Char 255 Bytes
Varchar 65,535 Bytes
Binary 255 Bytes
Varbinary 65,535 Bytes
TinyBlob 255 Bytes
TinyText 255 Bytes
Blob 65,535 Bytes (2^16 -1)
Text 65,535 Bytes (2^16 -1)
Medium Blob 16,777,215 Bytes (2^24 -1)
Medium Text 16,777,215 Bytes (2^24 -1)
LongBlog 4,294,967,295 Bytes (2^32 -1)
LongText 4,294,967,295 Bytes (2^32 -1)
Bit Range from 1 to 64
Tinyint The signed range is -128 to 127. The unsigned range is 0 to 255.
BOOL, BOOLEAN true or false
SmallInt The signed range is -32768 to 32767. The unsigned range is 0 to 65535.
MediumInt The signed range is -8388608 to 8388607. The unsigned range is 0 to 16777215.
Int/Integer The signed range is -2147483648 to 2147483647. The unsigned range is 0 to 4294967295.
BigInt The signed range is -9223372036854775808 to 9223372036854775807. The unsigned range
is 0 to 18446744073709551615.
Float Allowable values are -3.402823466E+38 to -1.175494351E-38, 0, and 1.175494351E-38
to 3.402823466E+38.
Double Allowable values are -1.7976931348623157E+308 to -2.2250738585072014E-308, 0, and
2.2250738585072014E-308 to 1.7976931348623157E+308.

(continue reading…)


  •   
  • Copyright © 1996-2010 BlogmyQuery - BMQ. All rights reserved.
    iDream theme by Templates Next | Powered by WordPress