Difference between revisions of "Talk:SQL"

From Organic Design wiki
(rv moving content to SQL)
(Notes on correct query)
 
Line 8: Line 8:
 
*hooks used
 
*hooks used
 
*hooks defined
 
*hooks defined
 +
 +
==Building up the query==
 +
: SELECT page_latest FROM page, categorylinks
 +
: WHERE cl_to = "Portal" AND cl_from = page_id;
 +
 +
:SELECT rev_text_id FROM revision
 +
: WHERE rev_id IN (SELECT page_latest FROM page, categorylinks WHERE cl_to = "Portal" AND cl_from = page_id);
 +
 +
;This is slow dues to a lack of indexing
 +
:SELECT * FROM text WHERE old_id IN (SELECT rev_text_id FROM revision
 +
:WHERE rev_id IN (SELECT page_latest FROM page, categorylinks WHERE cl_to = "Portal" AND cl_from = page_id));
 +
 +
;Two parts step 1;
 +
:SELECT page_latest FROM page, categorylinks WHERE cl_to = "Portal" AND cl_from = page_id)
 +
;step 2
 +
:SELECT * FROM text WHERE old_id IN (SELECT rev_text_id FROM revision
 +
:WHERE rev_id IN (3031, 3033)
 +
 +
;Select statement that works
 +
:SELECT  old_text FROM {{SQLprefix}}text, {{SQLprefix}}revision
 +
:WHERE old_id = rev_text_id and rev_id IN (
 +
:  SELECT page_latest FROM {{SQLprefix}}page, {{SQLprefix}}categorylinks
 +
:  WHERE cl_to = "Portal" and cl_from = page_id );

Latest revision as of 03:53, 27 May 2008

I need to add links to an article I have on SQL, I also propose a section listing every mediawiki extension that contains SQL queries --Sven 14:09, 11 February 2008 (NZDT)

Sounds like a job for SMW - adding script related properties to them all. Or maybe to their talk pages since scripts aren't wikitext articles - or could add a namespace for that - like properties:? --Nad 14:26, 11 February 2008 (NZDT)

Ideas for script-related properties

  • has db queries
  • classes/methods used
  • classes defined
  • hooks used
  • hooks defined

Building up the query

SELECT page_latest FROM page, categorylinks
WHERE cl_to = "Portal" AND cl_from = page_id;
SELECT rev_text_id FROM revision
WHERE rev_id IN (SELECT page_latest FROM page, categorylinks WHERE cl_to = "Portal" AND cl_from = page_id);
This is slow dues to a lack of indexing
SELECT * FROM text WHERE old_id IN (SELECT rev_text_id FROM revision
WHERE rev_id IN (SELECT page_latest FROM page, categorylinks WHERE cl_to = "Portal" AND cl_from = page_id));
Two parts step 1;
SELECT page_latest FROM page, categorylinks WHERE cl_to = "Portal" AND cl_from = page_id)
step 2
SELECT * FROM text WHERE old_id IN (SELECT rev_text_id FROM revision
WHERE rev_id IN (3031, 3033)
Select statement that works
SELECT old_text FROM 1120_text, 1120_revision
WHERE old_id = rev_text_id and rev_id IN (
SELECT page_latest FROM 1120_page, 1120_categorylinks
WHERE cl_to = "Portal" and cl_from = page_id );