Hey , its very easy . Its just using two queries and a simple UNION…
for simplication , i m diving the query, the first one is
select A.id from (select id from graph order by id asc limit 1) A // this will give the lowest id , similarly
select B.id from (select [...]
Archive for the 'mysql' Category
How to get first and last record in mysql
January 6, 2009Longest query of my life
December 17, 2008mysql -H -u mauj -p mauj -e “select count(*) as DownloadCount,W.phone as PhoneModel,sum(W.un) as NumberOfUser from (select count(*) as un,mo ,phone from wap_tran_1 where servid=1 and type=3 and ts like ‘%2008-01%’ group by phone,mo UNION select count(*) as un,mo ,phone from wap_tran_2 where servid=1 and type=3 and ts like ‘%2008-01%’ group by phone,mo UNION select [...]
how to start/stop mysql in windows in dos
April 21, 2008DOSĀ > net start mysql
this will start mysql
DOS> net stop mysql
this will stop mysql
mysql transaction
April 19, 2008it is the set of instructions or queries i.e is either executed or rolled backas a single atomic unit.
berkeleyDB and mysql are two storage engines that support mysql transaction.
mysql table locks
April 19, 2008There is 3 types of table locking.
1) table level locking // locks the entire table
2) page level locking // locks some [...]
how to format the date in mysql
April 15, 2008select date_format(filed_name, ‘%d/%m/%Y/%T’) as formated_date from tablename
how to know the user , date and version of mysql
April 15, 2008select user(), now(), version()
Replication in mysql
April 14, 2008Here are the steps to create replication in mysql
1) All the information should be stored in master.info file .
2) Create user for replication.
example suppose i want to give permission to user ‘pravin’ for ‘mydomain.com’ , then
grant replication slave on *.* to ‘pravin’@’mydomain.com’ identified by ’slavepass’
Here you can create the new uses also .
3) Setting the [...]
grant command in mysql
April 7, 2008grant all on test1.* to ‘username’@’localhost’ identified by ‘password’
how to generate csv files from select statement
April 7, 2008SELECT id,title INTO OUTFILE ‘/tmp/6300_content.csv‘ FIELDS TERMINATED BY ‘,’ OPTIONALLY ENCLOSED BY ‘ ” ‘ LINES TERMINATED BY ‘\n’ FROM service_1 where handset like ‘%6300%’;
here /tmp/6300_content.csv is the path where the files needed to store
Fields are terminated by comma ( , )
Lines are terminated by ( \n )