Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6731903
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T10:35:04+00:00 2026-05-26T10:35:04+00:00

I just realized my mistake! I used the table jokecategory twice… learning PHP is

  • 0

I just realized my mistake! I used the table jokecategory twice… learning PHP is a humbling experience…

Thank you for your help, so far so good!


Sorry I didn’t paste in the SQL, but your advice helped nonetheless. I modified the SQL query to use “AS”, however I think I mixed something up with the “category” table. Can’t figure out what, but it’s not allowing me to search based on category now. Any ideas? I am receiving the following error:

Error: Not unique table/alias: ‘jokecategory’

SQL query:

    $select = 'SELECT DISTINCT joke.id, joke.joketext, author.id AS author_name, author.name AS author_name, jokecategory.jokeid AS cat_jokeid, jokecategory.categoryid AS joke_catid, category.id AS cat_id, category.name as cat_name'; 
$from   = ' FROM joke, author, jokecategory, category'; 
$where = ' WHERE joke.authorid = author.id AND joke.id = jokecategory.jokeid AND jokecategory.categoryid = category.id';


$aid = $_POST['aid']; 
if ($aid != '') { // An author is selected
    $where .= " AND authorid='$aid'";
}

$cid = $_POST['cid']; 
if ($cid != '') { // A category is selected
    $from .= ', jokecategory'; 
    $where .= " AND joke.id=jokecategory.jokeid AND categoryid='$cid'";
}

$tid = $_POST['tid'];
if ($tid != '') { // A theme is selected
    $from .= ', joketheme';
    $where .= " AND joke.id=joketheme.jokeid AND themeid='$tid'";
}

$gfid = $_POST['gfid'];
if ($gfid != '') { // A region is selected
    $from .= ', jokegeofocus';
    $where .= " AND joke.id=jokegeofocus.jokeid AND geofocusid='$gfid'";
}

$searchtext = $_POST['searchtext']; 
if ($searchtext != '') { // Some search text was specified
    $where .= " AND joketext LIKE '%$searchtext%'";
    }

?>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T10:35:04+00:00Added an answer on May 26, 2026 at 10:35 am

    We don’t see your SQL query, but you should be supplying column aliases for ambiguous columns with the AS keyword, as in:

    SELECT 
      t1.name AS t1name,
      t2.name AS t2name
    FROM
      t1 
      JOIN t2 ON t1.id = t2.id
    

    These would then be accessed in a fetched row by their aliases:

    while ($joke = mysql_fetch_array($jokes)) { 
      echo "Table 1 name: {$joke['t1name']}\n";
      echo "Table 2 name: {$joke['t2name']}\n";
    }
    

    A further suggestion (though again since we don’t see the SQL it may be moot), is to be explicit about which columns you select.

    Rather than doing

    SELECT t1.*, t2.*
    

    a better practice is to explicitly list the columns you need:

    SELECT t1.name, t2.id, t2.category .... t2.whatever 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm currently designing a website and just realized it would help me a lot
I just realized that after learning a lot about various scheduling algorithms, how a
I just realized that in some place in my code I have the return
I just realized from an article in CACM that Doxygen works with Java (and
I just realized that I need to synchronize a significant amount of data collection
I just realized something crazy, which I assumed to be completely impossible : when
I just realized a function may be defined inside another function in C: void
I just realized that the method Element.getElementsByTagName(someTagName) returns a nodelist of all elements in
I just realized that i may not be following best practices in regards to
I am testing my webpage on a server using preview dns. Just realized that

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.