MySQL

  1. Select random rows from a table in MySQL

    In order to select a random row from MySQL, we can order the rows by a random number and then pick the first row.

    SELECT * FROM node ORDER BY rand() limit 1;

    The above query randomly selects a row from the table node.

    read on

  2. Resolve Net::MySQL Hang problem if the database result has only 1 row or is empty

    Net::MySQL is a simple MySQL perl Client to connect to MySQL servers. But Net::MySQL hangs if your result set is having just one row.

    Sample Net::MySQL code

    #!/usr/bin/perl use Net::MySQL; $mysql = Net::MySQL->new( hostname => 'localhost', database => 'db', user => 'user', password = … read on

Tags
On Facebook
Email Newsletter