Friday, February 14, 2014

How to drop a column from table

Execute below query to get desire result

Alter Table 'table_name'
Drop Column 'Column_Name

Saturday, February 1, 2014

How to select random row from MySQL Database

1. Select top 1 * from 'table_name' order by NEWID()
    Above query return 1 row on the random basic.. row might be repeat .

2. Select top 1 * from 'table_name' where Id=(select (RAND()*Count(Id)) from 'table_name')
    Above query return 1 row from total rows present in table on random basic .. row might be repeat .
    note : Id is the Column name and Id must be in sequence and unique

3. Select top 1 * from 'table_name' where Id=(select Floor(RAND()*Count(Id)) from 'table_name')
    Frequency of repeat row might be less