1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

XF 1.4 Query to find unassigned prefixes?

Discussion in 'XenForo Questions and Support' started by Kevin, Aug 8, 2015.

  1. Kevin

    Kevin Well-Known Member

    After the dust has settled of doing a few forum merges I'm cleaning up stuff.

    Can anybody suggest a query to run to find prefixes that are not assigned to any forums?
     
  2. Chris D

    Chris D XenForo Developer Staff Member

    I think this should do it:
    Code:
    SELECT *
    FROM xf_thread_prefix AS tp
    WHERE (
        SELECT prefix_id
        FROM xf_forum_prefix AS fp
        WHERE fp.prefix_id = tp.prefix_id
    ) IS NULL
    It should return a list of all prefixes that don't have a forum association.
     
    Kevin likes this.
  3. Kevin

    Kevin Well-Known Member

    Chris, thanks, that'll take care of exactly what I was looking for. (y)

    phpMyAdmin GUI was throwing an error because the inner select might return multiple rows so all I had to do was add a 'LIMIT 1' to the inner select.
    Code:
    SELECT *
    FROM xf_thread_prefix AS tp
    WHERE (
        SELECT prefix_id
        FROM xf_forum_prefix AS fp
        WHERE fp.prefix_id = tp.prefix_id
        LIMIT 1
    ) IS NULL
    
    For anybody reading this wanting to do the same thing, you can then take the prefix_id value in the results and use a URL like https://{YourXFURL}/admin.php?thread-prefixes/prefix.{prefixID}/edit to edit the prefix directly
     

Share This Page