Tags: mysql

Find MYSQL Duplicate records

In : mysql, Posted by admin on Mar.03, 2009

If the database has a table call employees. The values are:


ID           Name
1              a
2              b
3              a
4              c
5              b

You want to find the duplicate record but not the first one (ie, ID# 3 and 5). You can do the following:

select id from employees where id not in (select distinct id from employees group by name);



How FriendFeed uses MySQL to store schema-less data

In : mysql, Posted by admin on Mar.03, 2009

Here is a posting about how FriendFeed uses MySQL to store the Json object. Then it creates separate table for each meta field to store the meta data. I use similar method to store all the static data (for example, order payment and transaction information). This method is good for data which is relatively stable.

http://bret.appspot.com/entry/how-friendfeed-uses-mysql

Tags :


mysql output csv file

In : mysql, Posted by admin on Oct.10, 2008

Here is the code to output result to csv file.

SELECT order_id,product_name,qty
FROM orders
INTO OUTFILE '/tmp/orders.csv'
FIELDS TERMINATED BY ','
ENCLOSED BY '"'
LINES TERMINATED BY '\n'

Tags :