title: Using join within same table in database
body: <p><strong>In my table I have the following:</strong></p>
  
  <p><a href="https://i.stack.imgur.com/IvAXT.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/IvAXT.png" alt="Database"></a></p>
  
  <p>Here is what I am trying to do. I have a multi-lingual website, where my <code>change language</code> button goes through a check, to see if there is a page that is relative to the current one, in another language.</p>
  
  <p>Let's say I enter <code>www.example.com/contact-us</code> whenever I change language, in this case, lets say Norwegian. I want to see if there is any correlating page in Norwegian. Which in this case is <code>www.example.com/kontakt-oss</code></p>
  
  <p>I'm trying to use the value <code>language ID</code> which is the language I want <code>(2)</code>, and the current page, which is <code>contact-us</code>. How can I make a select query that outputs <code>kontakt-oss</code> from these two values?</p>
  
  <p>I've tried <code>LEFT JOIN</code> and <code>FULL OUTER JOIN</code>, but I can't seem to find a solution.</p>
  
  <pre><code>// CHECK IF PARALELL LANGUAGE PAGE
  $sql2 = "SELECT page_name "
  . "FROM pages "
  . "WHERE page_relations IN (SELECT page_relations FROM pages WHERE page_name = :pagename) AND page_lang = :language";
  $query2 = $db_connect-&gt;prepare($sql1);
  if($query2-&gt;execute(array(':pagename' =&gt; $get_website_page,':language' =&gt; $echomenu['language_id']))){
      echo "/test";
      var_dump("GO!");
  }
  else{
      var_dump("ERROR");
  }
  </code></pre>
  
  <p>I have checked the following values <code>get_website_page</code> outputs: contact-us</p>
  
  <p>And <code>$echomenu['language_id']</code> output: 2.</p>
  
  <p>However, query simple does not run and outputs ERROR.</p>