Never been to DZone Snippets before?

Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world

About this user

http://www.rbs.me.uk

« Newer Snippets
Older Snippets »
Showing 1-9 of 9 total  RSS 

Analyse a MySQL Table for Inefficiencies

// description of your code here

SELECT * FROM tags PROCEDURE ANALYSE()

Analyse a MySQL Query for inefficiencies

// description of your code here

EXPLAIN SELECT t2.dbid, t2.tag, COUNT(t2.dbid) * 20 AS match_count
FROM tags AS t1, tags AS t2
WHERE t1.dbid = '105318'
AND t2.tag = t1.tag
AND t1.dbid != t2.dbid
GROUP BY t2.dbid
ORDER BY match_count;

Return ordered list of near match items based on tag matches

// description of your code here

select t2.dbid, t2.tag, count(t2.dbid) as match_count from tags as t1, tags as t2 where t1.dbid = '105319' and t2.tag = t1.tag and t1.dbid != t2.dbid GROUP BY t2.dbid 1 ORDER BY match_count;

Output MySQL to a text file

// description of your code here

/opt/mysql/bin/mysql -u root -h mysql-server < q4.sql > ! out.txt

Start MySQL with LOAD LOCAL INFILE enabled

// description of your code here

/opt/mysql/bin/mysql -u root -h mysql-server --local-infile=1 

MySQL LOAD DATA LOCAL

// description of your code here

LOAD DATA LOCAL INFILE "/dc/elp/lionref/data/master/loggy.txt" INTO TABLE citations; 

Create Temporary MySQL Table

// description of your code here

USE reference;

CREATE TEMPORARY TABLE fulltxt
SELECT surname,atitle,title,type,journal,pqid,volume, issn,issue,spage,year
FROM citations
WHERE volume > 0
AND issue > 0
AND spage > 0
AND issn != ''
AND pqid != ''
; 

SELECT from multiple MySQL Tables

// description of your code here

SELECT fulltxt.pqid AS candidate_ft, citations.chid
FROM citations,fulltxt
WHERE citations.issn = fulltxt.issn
AND citations.volume = fulltxt.volume
AND citations.issue = fulltxt.issue
AND citations.year = fulltxt.year
AND citations.spage = fulltxt.spage
AND citations.pqid = ''
; 

query same table simultaneously with mysql

// description of your code here

USE reference;

SELECT c2.pqid AS candidate,c1.surname,c1.atitle,c1.title,c1.type,c1.journal,c1.pqid,c1.volume, c1.issn,c1.issue,c1.spage,c1.year
FROM citations AS c1, citations AS c2
WHERE c1.issn = c2.issn
AND c1.volume = c2.volume
AND c1.issue = c2.issue
AND c1.year = c2.year
AND c1.spage = c2.spage
AND c1.pqid != c2.pqid
AND c1.pqid = ''
; 
« Newer Snippets
Older Snippets »
Showing 1-9 of 9 total  RSS