Difference between revisions of "MediaWiki/Sql"
Jump to navigation
Jump to search
(syntax / typo) |
(link to Manual and taged help) |
||
(5 intermediate revisions by one other user not shown) | |||
Line 1: | Line 1: | ||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
Here is a query that will show you the pages in your wiki that contain a particular string. In this example, I wanted to find all pages that were using the 'Icon' extension parser extension magic word '#icon'. | Here is a query that will show you the pages in your wiki that contain a particular string. In this example, I wanted to find all pages that were using the 'Icon' extension parser extension magic word '#icon'. | ||
− | <source lang=" | + | <source lang="sql"> |
− | SELECT DISTINCT | + | SELECT DISTINCT page_title |
− | + | FROM page | |
− | FROM | + | RIGHT JOIN revision ON page_id = rev_page |
− | + | WHERE rev_text_id | |
− | + | IN ( | |
− | + | SELECT old_id | |
− | + | FROM `text` | |
− | WHERE | + | WHERE old_text LIKE '%#icon%' |
− | + | ) | |
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
</source> | </source> | ||
− | |||
− | |||
− | |||
− | |||
− | + | == See Also == | |
+ | * [[mw:Manual:Database_access]] | ||
[[Category:Database]] | [[Category:Database]] | ||
Line 103: | Line 20: | ||
[[Category:Development]] | [[Category:Development]] | ||
[[Category:Help]] | [[Category:Help]] | ||
− | |||
− |
Revision as of 12:34, 31 October 2008
Here is a query that will show you the pages in your wiki that contain a particular string. In this example, I wanted to find all pages that were using the 'Icon' extension parser extension magic word '#icon'.
SELECT DISTINCT page_title
FROM page
RIGHT JOIN revision ON page_id = rev_page
WHERE rev_text_id
IN (
SELECT old_id
FROM `text`
WHERE old_text LIKE '%#icon%'
)